Boa: catch statement causes syntax error

Created on 7 May 2020  路  3Comments  路  Source: boa-dev/boa

try {
        var x = 1;
}
catch (e) { }
ParsingError: Expected token '(', got 'catch' in catch in try statement at line 4, col 1
bug good first issue E-Easy parser

All 3 comments

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.

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

Sure! Tell us if you need any help :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

croraf picture croraf  路  4Comments

joshwd36 picture joshwd36  路  4Comments

jasonwilliams picture jasonwilliams  路  4Comments

IovoslavIovchev picture IovoslavIovchev  路  4Comments

elasmojs picture elasmojs  路  4Comments