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

catch statement causes syntax error #375

Closed
gadget114514 opened this issue May 7, 2020 · 3 comments · Fixed by #390
Closed

catch statement causes syntax error #375

gadget114514 opened this issue May 7, 2020 · 3 comments · Fixed by #390
Assignees
Labels
bug Something isn't working E-Easy Easy good first issue Good for newcomers parser Issues surrounding the parser
Milestone

Comments

@gadget114514
Copy link

gadget114514 commented May 7, 2020

try {
        var x = 1;
}
catch (e) { }
ParsingError: Expected token '(', got 'catch' in catch in try statement at line 4, col 1
@Razican Razican added bug Something isn't working E-Easy Easy good first issue Good for newcomers parser Issues surrounding the parser labels May 7, 2020
@Razican Razican added this to the v0.8.0 milestone May 7, 2020
@Razican
Copy link
Member

Razican commented May 7, 2020

Good "catch"!
The issue is in boa/src/syntax/parser/statement/try_stm/mod.rs#L67. We peek() the next token, and check if it's the catch keyword, but then, we don't consume it.

We should divide this parser into TryStatement, Catch, Finally and CatchParameter, as we can see in the spec. Then, decide if we should parse Catch or Finally depending on the peek(). Those parsers should then expect() the catch/finally keywords.

@abhijeetbhagat
Copy link
Contributor

I can take this up if no one else is working.

@HalidOdat
Copy link
Member

Sure! Tell us if you need any help 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working E-Easy Easy good first issue Good for newcomers parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants