Skip to content

fix(parser): parse new (import("x")) with preserveParens: false#11251

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-23-fix_parser_parse_new_import_x_with_preserveparens_false_
May 23, 2025
Merged

fix(parser): parse new (import("x")) with preserveParens: false#11251
graphite-app[bot] merged 1 commit intomainfrom
05-23-fix_parser_parse_new_import_x_with_preserveparens_false_

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 23, 2025

fixes #11183

No unit tests added, I will enable preserveParens: false in
the conformance test in the near future.

Copilot AI review requested due to automatic review settings May 23, 2025 15:31
@github-actions github-actions bot added the A-parser Area - Parser label May 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

The PR fixes the parsing behavior for new (import("x")) by ensuring that an error is only generated for the dynamic import used directly with the new operator when preserveParens: false is enabled.

  • Introduces a new boolean flag to detect the import keyword before parsing.
  • Adjusts the error-checking condition to incorporate the new flag.
Comments suppressed due to low confidence (1)

crates/oxc_parser/src/js/expression.rs:894

  • Consider adding unit or conformance tests to verify the behavior of dynamic imports with the new operator both with and without parentheses.
if is_import && matches!(callee, Expression::ImportExpression(_)) {

Copy link
Member Author

Boshen commented May 23, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-bug Category - Bug label May 23, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 23, 2025

CodSpeed Instrumentation Performance Report

Merging #11251 will not alter performance

Comparing 05-23-fix_parser_parse_new_import_x_with_preserveparens_false_ (dcdcf12) with main (0c1f382)

Summary

✅ 38 untouched benchmarks

@graphite-app
Copy link
Contributor

graphite-app bot commented May 23, 2025

Merge activity

…11251)

fixes #11183

No unit tests added, I will enable `preserveParens: false` in
the conformance test in the near future.
@graphite-app graphite-app bot force-pushed the 05-23-fix_parser_parse_new_import_x_with_preserveparens_false_ branch from 0e15be1 to dcdcf12 Compare May 23, 2025 15:38
@graphite-app graphite-app bot merged commit dcdcf12 into main May 23, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 05-23-fix_parser_parse_new_import_x_with_preserveparens_false_ branch May 23, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser: new (import("x")) should not report Cannot use new with dynamic import error with preserveParens: false

2 participants