Skip to content

Token missing error on EOF shows confusing message #11460

@v0idpwn

Description

@v0idpwn

Environment

  • Elixir & Erlang/OTP versions (elixir --version): 1.13.0
  • Operating system: Mac OS Big Sur 11.6

Current behavior

When the following snippet is evaluated:

# foo.exs
defmodule Foo do
  :hello

It shows the following error:

** (TokenMissingError) foo.exs:3:1: missing terminator: end (for "do" starting at line 1)
    |
  3 | 
    | ^
    (elixir 1.13.0) lib/code.ex:1183: Code.require_file/2

The tokenizer raises the token missing error when reaching the EOF, then mentioning a line that doesn't exist (file line count + 1, in this case, 3), and the exception displays an empty line.

Expected behavior

Either:

  • show a special indicator of EOF in the snippet
  • mention in the exception message that the file ended
  • mention in the exception message that the file ended & don't show the snippet

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions