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

Lexing and Parsing errors should throw a SyntaxError #539

Closed
HalidOdat opened this issue Jul 2, 2020 · 3 comments · Fixed by #567
Closed

Lexing and Parsing errors should throw a SyntaxError #539

HalidOdat opened this issue Jul 2, 2020 · 3 comments · Fixed by #567
Assignees
Labels
bug Something isn't working execution Issues or PRs related to code execution
Milestone

Comments

@HalidOdat
Copy link
Member

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Any invalid syntax like {.

Expected behavior
The expected behavior would be a SyntaxError with the parser error.

Actual behavior
we get a panic with the message.

Additional context
I think the best way to implement this would be to have the lexer and parser, generate the error as we do now but not panic, and in forward we check if lexing or parsing failed and then throw a SyntaxError, this would eliminate the need to introduce the Interpreter to the lexer/parser which would keep the code cleaner.

This is blocked until #536 lands

@HalidOdat HalidOdat added bug Something isn't working blocked Waiting for another code change execution Issues or PRs related to code execution labels Jul 2, 2020
@HalidOdat HalidOdat added this to the v0.10.0 milestone Jul 2, 2020
@Razican
Copy link
Member

Razican commented Jul 2, 2020

Hmmm this is interesting, where do we panic? I thought we just returned a parsing/lexing error.

@HalidOdat
Copy link
Member Author

Hmmm this is interesting, where do we panic? I thought we just returned a parsing/lexing error.

Sorry about that, we don't panic but we print the parsing error and exit https://github.com/boa-dev/boa/blob/master/boa/src/lib.rs#L83-L85

@HalidOdat HalidOdat removed the blocked Waiting for another code change label Jul 2, 2020
@Razican
Copy link
Member

Razican commented Jul 3, 2020

Hmmm this is interesting, where do we panic? I thought we just returned a parsing/lexing error.

Sorry about that, we don't panic but we print the parsing error and exit /boa/src/lib.rs@master#L83-L85

True, that should throw a Syntax Error :)

@Razican Razican self-assigned this Jul 15, 2020
@Razican Razican linked a pull request Jul 15, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working execution Issues or PRs related to code execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants