Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Nov 15, 2025

Error on invalid modifiers before module and global declarations.

Previously illegal syntax like this would be parsed without error:

protected accessor readonly async declare global {}
protected accessor readonly async global {}
protected accessor readonly async module "foo" {}

Discovered this bug while working on #15712.

Similar to #11713.

Copy link
Member Author

overlookmotel commented Nov 15, 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.

@overlookmotel overlookmotel marked this pull request as ready for review November 15, 2025 15:34
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 15, 2025

CodSpeed Performance Report

Merging #15723 will not alter performance

Comparing 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ (4e1248e) with main (c167dfa)

Summary

✅ 37 untouched

@overlookmotel overlookmotel self-assigned this Nov 15, 2025
@overlookmotel overlookmotel requested a review from Boshen November 17, 2025 17:37
@overlookmotel overlookmotel force-pushed the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch from 3d430d9 to 522810e Compare November 17, 2025 18:17
@overlookmotel overlookmotel force-pushed the 11-15-perf_transformer_typescript_reverse_order_of_checks branch from 74572d3 to 6b4cdae Compare November 17, 2025 18:17
@graphite-app graphite-app bot changed the base branch from 11-15-perf_transformer_typescript_reverse_order_of_checks to graphite-base/15723 November 17, 2025 19:26
@graphite-app graphite-app bot force-pushed the graphite-base/15723 branch from 6b4cdae to cbb27fd Compare November 17, 2025 19:31
@graphite-app graphite-app bot requested a review from Dunqing as a code owner November 17, 2025 19:31
@graphite-app graphite-app bot force-pushed the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch from 522810e to 6fcc1a5 Compare November 17, 2025 19:31
@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label Nov 17, 2025
@graphite-app graphite-app bot changed the base branch from graphite-base/15723 to main November 17, 2025 19:31
@graphite-app graphite-app bot force-pushed the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch 2 times, most recently from 3f085e4 to 8523f78 Compare November 17, 2025 19:35
Copilot AI review requested due to automatic review settings November 17, 2025 19:55
@overlookmotel overlookmotel force-pushed the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch from 8523f78 to 4e1248e Compare November 17, 2025 19:55
Copilot finished reviewing on behalf of overlookmotel November 17, 2025 19:57
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

This PR adds validation to forbid invalid modifiers on module and global declarations in TypeScript. Previously, illegal syntax with multiple modifiers (like protected accessor readonly async declare global {}) would be parsed without error.

  • Adds verify_modifiers calls to validate that only the declare modifier is allowed on module and global declarations
  • Ensures consistency with similar validation done for other TypeScript declarations (enums, type aliases, interfaces)

Reviewed Changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_parser/src/ts/statement.rs Adds modifier validation for parse_ambient_external_module_declaration, parse_module_or_namespace_declaration, and parse_ts_global_declaration functions to reject invalid modifiers
tasks/coverage/snapshots/parser_typescript.snap Updates test snapshots to reflect new error messages for invalid export modifier on module declarations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 18, 2025
Copy link
Member

Boshen commented Nov 18, 2025

Merge activity

  • Nov 18, 1:54 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Nov 18, 1:54 AM UTC: Boshen added this pull request to the Graphite merge queue.
  • Nov 18, 2:00 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Conformance').
  • Nov 18, 11:42 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Nov 18, 11:49 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Nov 18, 11:49 AM UTC: Merged by the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Nov 18, 2025
Error on invalid modifiers before `module` and `global` declarations.

Previously illegal syntax like this would be parsed without error:

```ts
protected accessor readonly async declare global {}
protected accessor readonly async global {}
protected accessor readonly async module "foo" {}
```

Discovered this bug while working on #15712.

Similar to #11713.
@graphite-app graphite-app bot force-pushed the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch from 4e1248e to 6f597bd Compare November 18, 2025 01:54
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 18, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Nov 18, 2025
Error on invalid modifiers before `module` and `global` declarations.

Previously illegal syntax like this would be parsed without error:

```ts
protected accessor readonly async declare global {}
protected accessor readonly async global {}
protected accessor readonly async module "foo" {}
```

Discovered this bug while working on #15712.

Similar to #11713.
@camc314 camc314 force-pushed the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch from 6f597bd to d4ff004 Compare November 18, 2025 11:43
@graphite-app graphite-app bot merged commit d4ff004 into main Nov 18, 2025
22 checks passed
@graphite-app graphite-app bot deleted the 11-15-fix_parser_forbid_invalid_modifiers_on_module_and_global_ branch November 18, 2025 11:49
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants