Skip to content

JS: Fix import-related parsing - #23227

Open
MathiasVP wants to merge 5 commits into
github:mainfrom
MathiasVP:fix-js-meta-dot-parsing
Open

MathiasVP wants to merge 5 commits into
github:mainfrom
MathiasVP:fix-js-meta-dot-parsing

Conversation

@MathiasVP

@MathiasVP MathiasVP commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes two parsing bugs:

  1. Statements starting with import.meta. For example:
    import.meta.hot.accept();
  2. Expression statements starting with dynamic import(...) followed by non-subscript operators. For example:
    import("./mod.js") || fallback();

Commit-by-commit review recommended.

DCA was uneventful.

MathiasVP and others added 5 commits November 24, 2026 13:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MathiasVP
MathiasVP requested review from a team as code owners November 24, 2026 12:58
Copilot AI adaptive review requested due to automatic review settings November 24, 2026 12:58

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.

🔵 Needs a closer look

The new expression-continuation path combines multiple grammar stages in the shared JavaScript parser, requiring broader review of precedence and parser-state interactions.

No open issues 🎉

What changed in this PR

Fixes two import-related parsing bugs in the JavaScript extractor so expression statements beginning with import.meta or dynamic import(...) are parsed completely.

Changes:

  • Adds reusable parsing helpers to continue from an already-parsed expression atom.
  • Routes import-led statements through full expression parsing, including operators beyond property access and calls.
  • Adds regression fixtures and expected extraction output covering operators, comments, and whitespace.
File Description
javascript/​extractor/​tests/​esnext/​output/​trap/​import-meta.js.trap Expected extraction output for import.meta cases.
javascript/​extractor/​tests/​esnext/​output/​trap/​dynamic-import-expr.js.trap Expected extraction output for dynamic-import expressions.
javascript/​extractor/​tests/​esnext/​input/​import-meta.js Regression cases for import-meta statements and whitespace variants.
javascript/​extractor/​tests/​esnext/​input/​dynamic-import-expr.js Regression cases for dynamic imports with logical, conditional, and comma operators.
javascript/​extractor/​src/​com/​semmle/​jcorn/​Parser.java Extracts expression-continuation helpers.
javascript/​extractor/​src/​com/​semmle/​jcorn/​ESNextParser.java Uses full expression parsing for import-led statements.

Review effort: Balanced (adaptive)

@github-actions github-actions Bot added the JS label Nov 24, 2026

This branch has not been deployed

No deployments
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