Skip to content

JS: Allow destructuring rest parameters - #22633

Draft
asgerf wants to merge 6 commits into
github:mainfrom
asgerf:js/remove-destructuring-error-checking
Draft

asgerf wants to merge 6 commits into
github:mainfrom
asgerf:js/remove-destructuring-error-checking

Conversation

@asgerf

@asgerf asgerf commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Simpler version of #22629 where we stop trying to do rigorous syntax-checking for pattern-specific errors. This means we now accept invalid-but-harmless things like a trailing comma after a rest parameter.

With that change in place, supporting destructuring rest parameters is just a matter removing a check that is no longer needed. It's actually ends up being a simplification.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The removed type guard can cause an uncaught ClassCastException for parenthesized async rest parameters.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Simplifies Jcorn’s destructuring parsing and enables array/object destructuring in JavaScript rest parameters.

Changes:

  • Removes delayed pattern-specific syntax diagnostics.
  • Allows destructuring rest parameters and permissive trailing commas.
  • Adds parser, extraction, and data-flow coverage.
File Description
javascript/​ql/​test/​library-tests/​TripleDot/​tst.js Tests flow through destructured rest parameters.
javascript/​extractor/​tests/​es2015/​output/​trap/​restparms2.js.trap Updates generated extraction expectations.
javascript/​extractor/​test/​com/​semmle/​js/​extractor/​test/​RobustnessTests.java Tests permissive destructuring parsing.
javascript/​extractor/​src/​com/​semmle/​jcorn/​Parser.java Simplifies parsing and permits destructured rest parameters.
javascript/​extractor/​src/​com/​semmle/​jcorn/​jsx/​JSXParser.java Adapts JSX parser signatures.
javascript/​extractor/​src/​com/​semmle/​jcorn/​flow/​FlowParser.java Adapts Flow parser signatures.
javascript/​extractor/​src/​com/​semmle/​jcorn/​ESNextParser.java Adapts ESNext parser signatures.
javascript/​extractor/​src/​com/​semmle/​jcorn/​CustomParser.java Adapts custom parser signatures.
javascript/​extractor/​src/​com/​semmle/​jcorn/​AngularExpressionParser.java Adapts Angular parser signatures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread javascript/extractor/src/com/semmle/jcorn/Parser.java
@github-actions github-actions Bot added the JS label Sep 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new pattern check rejects valid member-expression targets in destructuring assignments.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread javascript/extractor/src/com/semmle/jcorn/Parser.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The parser simplification is consistently propagated across subclasses and covered by extraction, robustness, and data-flow tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants