Skip to content
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

[JavaScript] anonymousFunction shouldn't contain functionDeclaration #3387

Closed
ris58h opened this issue May 8, 2023 · 0 comments · Fixed by #3388
Closed

[JavaScript] anonymousFunction shouldn't contain functionDeclaration #3387

ris58h opened this issue May 8, 2023 · 0 comments · Fixed by #3388

Comments

@ris58h
Copy link
Contributor

ris58h commented May 8, 2023

The rules below are from the current JavaScriptParser.g4:

anonymousFunction
    : functionDeclaration                                                       # FunctionDecl
    | Async? Function_ '*'? '(' formalParameterList? ')' functionBody    # AnonymousFunctionDecl
    | Async? arrowFunctionParameters '=>' arrowFunctionBody                     # ArrowFunction
    ;
functionDeclaration
    : Async? Function_ '*'? identifier '(' formalParameterList? ')' functionBody
    ;

It seems like functionDeclaration shouldn't be a part of anonymousFunction. First of all it is clearly not anonymous. Also such rules produce a complex tree for a named async function: for code async function fetchNext(continuation) {} the statement subtree is (expressionStatement (expressionSequence (singleExpression (anonymousFunction (functionDeclaration ...)))) instead of just (functionDeclaration ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants