Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the code surrounding the position of a parse error #127

Closed
yannham opened this issue Aug 20, 2020 · 0 comments · Fixed by #128
Closed

Show the code surrounding the position of a parse error #127

yannham opened this issue Aug 20, 2020 · 0 comments · Fixed by #128

Comments

@yannham
Copy link
Member

yannham commented Aug 20, 2020

Is your feature request related to a problem? Please describe.
Parse errors could be more user-friendly. They currently include the location of the problem, but do not take advantage of the error reporting infrastructure which is capable of showing the incriminated snippet. Compare this:

$nickel <<< '%a" '
error: While parsing: Invalid token at 870

to a type error:

error: Type error
  ┌─ <stdin>:1:5
  │
1 │ 1 + "a"
  │     ^^^ This expression has type Str, but Num was expected
  │
  = +, 2nd argument

Describe the solution you'd like
Parse errors show the incriminated snippets, as do evaluation errors:

$nickel <<< '%a" '
error: Parse error
  ┌─ <stdin>:1:5
  │
1 │ %a"
  │ ^ Invalid token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant