-
Notifications
You must be signed in to change notification settings - Fork 31
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
More helpful syntax error messages #9
Comments
And for contexts where colour doesn't show up, show the line number and offset also. Significantly improves #9.
Here's what we have as of bf7bb54, shown in the REPL: An illegal identifier occurring in a built-in macro is highlighted in source. This should work with any error returned by esvalid, but I haven't tested it comprehensively. As you can see in the last command, the invalid AST node originating from the user-defined macro It would be good to at least display the macro's name ( |
Could this be implemented via an env::fail() method? That could also be potentially useful for macro writers as well, if they need to fail with a more descriptive error than simply "Oh, by the way, this will break if you're not careful", which is a common problem with macros, especially when you're dealing with DSLs. I was just thinking of this when I was working on #41. That as a high-level method might be the best way to do it, and it would definitely be worth exposing. |
@isiahmeadows I've just had macros throw an error when user input is nonsensical. However, the compilation env makes no attempt to catch errors from macros at the moment. Hence the stack traces don't tell you useful stuff e.g. which macro it was that errored. I think catching would be a better way than an |
f19be37 now catches macro errors and adds diagnostic data before rethrowing. Thanks for raising that. |
Syntax errors look like this right now:
The
SyntaxError
-object sexpr-plus returns hasline
andcolumn
properties. We should perhaps use them.Invalid AST errors look like this:
That's already getting there, but it would still be best if exact positions in code were passed on to AST nodes, so the error reporter could point out the exact in-source position that an error happened.
The text was updated successfully, but these errors were encountered: