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

Parser accepts trailing comma for ParenthesizedExpression, SequenceExpression #3878

Closed
aapoalas opened this issue Jun 24, 2024 · 0 comments · Fixed by #3885
Closed

Parser accepts trailing comma for ParenthesizedExpression, SequenceExpression #3878

aapoalas opened this issue Jun 24, 2024 · 0 comments · Fixed by #3885
Assignees
Labels
C-bug Category - Bug

Comments

@aapoalas
Copy link

Currently, oxc parser accepts a few invalid inputs related to trailing commas inside parenthesis, be the result a ParenthesizedExpression or a SequenceExpression. The following input causes no errors:

(2,);
(2,3,);

But if you try to run the same input in engine262, it fails on both lines: https://engine262.js.org/#code=BQJgNAlA3AUKYGZJSA%3D%3D&mode=script&features=

@aapoalas aapoalas added the C-bug Category - Bug label Jun 24, 2024
@Boshen Boshen self-assigned this Jun 24, 2024
Boshen pushed a commit that referenced this issue Jun 24, 2024
…#3885)

close: #3878

The implementation is copied from `SeparatedList`'s `print_list`.
```diff
    fn parse_list(&mut self, p: &mut ParserImpl<'a>) -> Result<()> {
        p.expect(self.open())?;

        let mut first = true;

        while !p.at(self.close()) && !p.at(Kind::Eof) {
            if first {
                first = false;
            } else {
                p.expect(self.separator())?;
-                if p.at(self.close()) {
-                    break;
-               }
            }

            self.parse_element(p)?;
        }

        p.expect(self.close())?;
        Ok(())
    }
```
@Boshen Boshen closed this as completed Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants