language-javascript icon indicating copy to clipboard operation
language-javascript copied to clipboard

Trailing commas in function application fail to parse

Open DanBurton opened this issue 5 years ago • 0 comments

λ> 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

DanBurton avatar Aug 26 '20 17:08 DanBurton