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

(<expression>,) is incorrectly treated as valid #726

Closed
gibson042 opened this issue Oct 26, 2021 · 3 comments
Closed

(<expression>,) is incorrectly treated as valid #726

gibson042 opened this issue Oct 26, 2021 · 3 comments
Labels
confirmed issue reported has been reproduced fixed - please verify Issue has been fixed. Please verify and close.

Comments

@gibson042
Copy link

Environment: XS 10.5.0

Description
XS seems to interpret a comma-terminated expression inside expression parentheses as valid, which it should not per CoverParenthesizedExpressionAndArrowParameterList:

Supplemental Syntax

When processing an instance of the production
PrimaryExpression[Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
the interpretation of CoverParenthesizedExpressionAndArrowParameterList is refined using the following grammar:

ParenthesizedExpression[Yield, Await] : ( Expression[+In, ?Yield, ?Await] )

Steps to Reproduce

// In value position
void (Date,);
// In a left-hand side
(Date,) = null;

Expected behavior
Each of the above statements should produce a SyntaxError.

Actual behavior
Both statements are accepted as equivalent to their valid counterparts that don't have the trailing comma.

@phoddie
Copy link
Collaborator

phoddie commented Oct 26, 2021

Hey @gibson042, thanks another detailed report. I'm able to duplicate your results. We'll take a look.

@phoddie phoddie added the confirmed issue reported has been reproduced label Oct 26, 2021
mkellner pushed a commit that referenced this issue Dec 8, 2021
mkellner pushed a commit that referenced this issue Dec 8, 2021
@phoddie
Copy link
Collaborator

phoddie commented May 24, 2022

(The two commits referenced above are mislabeled and do not apply to this report.)

@phoddie
Copy link
Collaborator

phoddie commented May 31, 2022

FYI – the issue is related to parsing arrow functions, strangely enough. The expression is (a, b, c, ) => {} (also with trailing comma inside parenthesis) is allowed because it is an arrow function. The parser needs a little more state to detect the error. This is expected to be resolved in XS 13.

mkellner pushed a commit that referenced this issue Jun 6, 2022
@phoddie phoddie added the fixed - please verify Issue has been fixed. Please verify and close. label Jun 6, 2022
@phoddie phoddie closed this as completed Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed issue reported has been reproduced fixed - please verify Issue has been fixed. Please verify and close.
Projects
None yet
Development

No branches or pull requests

2 participants