-
-
Notifications
You must be signed in to change notification settings - Fork 153
Closed
Labels
priority:lowlow priority for the project maintainers, contributions welcomelow priority for the project maintainers, contributions welcome
Description
In JavaScript, function at the start of a statement means the thing that comes after is parsed as a function statement, never an expression. So the following test case seems weird:
Function calls
============================================
x.someMethod(arg1, "arg2");
function(x, y) {
}(a, b);
---
(program
(expression_statement (call_expression
(member_expression (identifier) (property_identifier))
(arguments (identifier) (string))))
(expression_statement (call_expression
(function
(formal_parameters (identifier) (identifier))
(statement_block))
(arguments (identifier) (identifier)))))
I mean, the code doesn't parse in a real parser, so you could argue that anything that comes out of it is okay, but this is the only test that fails when I remove the (seemingly superfluous, because already part of $._expression via $._constructable_expression) $.function from the definition of call_expression, so I suspect it points at some confusion in the grammar definition.
call_expression: $ => prec(PREC.CALL, seq(
choice($._expression, $.super, $.function),
choice($.arguments, $.template_string)
)),
Metadata
Metadata
Assignees
Labels
priority:lowlow priority for the project maintainers, contributions welcomelow priority for the project maintainers, contributions welcome