Skip to content

Trailing commas in function application fail to parse #123

Open
@DanBurton

Description

@DanBurton
λ> parseModule "f(x)" "src"
Right (JSAstModule [JSModuleStatementListItem (JSMethodCall (JSIdentifier (JSAnnot (TokenPn 0 1 1) []) "f") (JSAnnot (TokenPn 1 1 2) []) (JSLOne (JSIdentifier (JSAnnot (TokenPn 2 1 3) []) "x")) (JSAnnot (TokenPn 3 1 4) []) JSSemiAuto)] (JSAnnot (TokenPn 0 0 0) []))
λ> parseModule "f(x,)" "src"
Left "RightParenToken {tokenSpan = TokenPn 4 1 5, tokenComment = []}"

Expected: f(x,) to parse as valid JavaScript (ECMAScript 2017 & up).
Actual: it doesn't

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#Function_calls

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions