Skip to content

fix(ast_tools): correctly parse define_index_type! macros#20580

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-15-fix_ast_tools_correctly_parse_define_index_type_macros
Mar 20, 2026
Merged

fix(ast_tools): correctly parse define_index_type! macros#20580
graphite-app[bot] merged 1 commit intomainfrom
om/02-15-fix_ast_tools_correctly_parse_define_index_type_macros

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Mar 20, 2026

Fix a bug in ast_tools. It was treating define_index_type! macro invocations the same as define_nonmax_u32_index_type!, and would have crashed if we tried to add an #[ast] attr to any types defined with define_index_type!.

Fix this - handle both macros correctly.

Copy link
Copy Markdown
Member Author

overlookmotel commented Mar 20, 2026


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 changes, fast-track this PR to the front of the merge queue

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.

Copy link
Copy Markdown
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 fixes ast_tools’ phase-1 loader so it distinguishes define_index_type! from define_nonmax_u32_index_type!, preventing incorrect skeleton generation (and downstream crashes) when #[ast]/#[ast_meta] is applied to index types defined via define_index_type!.

Changes:

  • Update macro dispatch to treat define_nonmax_u32_index_type! and define_index_type! as separate cases.
  • Parse the inner type correctly for define_index_type! (= Type) while hard-coding NonMaxU32 for define_nonmax_u32_index_type!.
  • Switch to building the synthetic ItemStruct via parse_quote! instead of manual ItemStruct construction.

@overlookmotel overlookmotel self-assigned this Mar 20, 2026
@overlookmotel overlookmotel force-pushed the om/02-15-perf_ast_tools_reduce_data_passing_between_functions branch from 677b327 to b94ce6b Compare March 20, 2026 22:02
@overlookmotel overlookmotel force-pushed the om/02-15-fix_ast_tools_correctly_parse_define_index_type_macros branch from 24e0b60 to 8e8f2c8 Compare March 20, 2026 22:02
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Mar 20, 2026

Merge activity

Fix a bug in `ast_tools`. It was treating `define_index_type!` macro invocations the same as `define_nonmax_u32_index_type!`, and would have crashed if we tried to add an `#[ast]` attr to any types defined with `define_index_type!`.

Fix this - handle both macros correctly.
@graphite-app graphite-app bot force-pushed the om/02-15-perf_ast_tools_reduce_data_passing_between_functions branch from b94ce6b to b4da52f Compare March 20, 2026 22:17
@graphite-app graphite-app bot requested a review from camc314 as a code owner March 20, 2026 22:17
@graphite-app graphite-app bot force-pushed the om/02-15-fix_ast_tools_correctly_parse_define_index_type_macros branch from 8e8f2c8 to f5ecb16 Compare March 20, 2026 22:17
@graphite-app graphite-app bot removed 0-merge Merge with Graphite Merge Queue labels Mar 20, 2026
Base automatically changed from om/02-15-perf_ast_tools_reduce_data_passing_between_functions to main March 20, 2026 22:24
@graphite-app graphite-app bot merged commit f5ecb16 into main Mar 20, 2026
24 checks passed
@graphite-app graphite-app bot deleted the om/02-15-fix_ast_tools_correctly_parse_define_index_type_macros branch March 20, 2026 22:25
costajohnt pushed a commit to costajohnt/oxc that referenced this pull request Mar 22, 2026
…ect#20580)

Fix a bug in `ast_tools`. It was treating `define_index_type!` macro invocations the same as `define_nonmax_u32_index_type!`, and would have crashed if we tried to add an `#[ast]` attr to any types defined with `define_index_type!`.

Fix this - handle both macros correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants