Skip to content

catch statement causes syntax error #375

Closed

Description

@gadget114514
try {
        var x = 1;
}
catch (e) { }
ParsingError: Expected token '(', got 'catch' in catch in try statement at line 4, col 1

Activity

  1. added
    A-Bug
    E-Easy
    Good First Issue
    C-Parser
    on May 7, 2020
  2. added this to the v0.8.0 milestone on May 7, 2020
  3. Razican commented on May 7, 2020

    @Razican
    Member

    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.

  4. abhijeetbhagat commented on May 7, 2020

    @abhijeetbhagat
    Contributor

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

  5. HalidOdat commented on May 7, 2020

    @HalidOdat
    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

Metadata

Metadata

Labels

A-BugC-ParserE-EasyGood First Issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions