-
Notifications
You must be signed in to change notification settings - Fork 47
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
Exception when parsing object literals containing arrow functions #116
Comments
I've also found a strange interplay between arrow functions and template literals: 0;``
// JSAstModule [JSModuleStatementListItem (JSDecimal '0',JSSemicolon),JSModuleStatementListItem (JSTemplateLiteral ((),'``',[]))]
()=>{};''
// JSAstModule [JSModuleStatementListItem (JSArrowExpression (()) => JSStatementBlock []),JSModuleStatementListItem (JSStringLiteral '')]
()=>{}``
// JSAstModule [JSModuleStatementListItem (JSTemplateLiteral ((JSArrowExpression (()) => JSStatementBlock []),'``',[]))]
()=>{};``
// JSAstModule [JSModuleStatementListItem (JSTemplateLiteral ((JSArrowExpression (()) => JSStatementBlock []),'``',[]))]
()=>{}
``
// JSAstModule [JSModuleStatementListItem (JSTemplateLiteral ((JSArrowExpression (()) => JSStatementBlock []),'``',[]))] Example 1 (no arrow function with a template literal) parses as expected. So does example 2 (arrow function with no template literal). Example 3 shouldn't parse, but does. The template literal should cause a syntax error. Example 4 should parse but not as a labeled template literal. The semicolon appears to be ignored. Example 5 should parse but not in the same way as 3 and 4. ASI doesn't appear to be respected in this case. |
I have a branch which fixes all of these cases. @erikd would you accept a PR? |
I noticed a parse error when parsing an object literal containing an arrow function if any properties are defined after the arrow function.
Since the third example parses without error, my suspicion is that the
,
in the failing example is being parsed as a comma operator and thus the colon afterx
is unexpected.The behavior also appears to be restricted to arrow functions as the fourth example contains an expression which doesn't cause a failure.
The text was updated successfully, but these errors were encountered: