Skip to content

fix(ast_tools): support u128 in assert_layouts generator#17050

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-18-fix_ast_tools_support_u128_in_assert_layouts_generator
Dec 18, 2025
Merged

fix(ast_tools): support u128 in assert_layouts generator#17050
graphite-app[bot] merged 1 commit intomainfrom
12-18-fix_ast_tools_support_u128_in_assert_layouts_generator

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 18, 2025

Previously u128 was not supported in assert_layouts generator, because Rust changed the alignment of u128 from 8 to 16 - and therefore the alignment depended on Rust version.

That change happened some time ago now, and all Rust versions above our MSRV have u128 with alignment of 16. So we can now support u128 (and also i128, NonZeroU128, NonZeroI128).

Also support u128 in raw_transfer and raw_transfer_lazy generators.

This will help with making lexer tokens serializable (#17025), since Token contains a u128.

@github-actions github-actions bot added A-ast-tools Area - AST tools C-bug Category - Bug labels Dec 18, 2025
Copy link
Member Author


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 force-pushed the 12-18-fix_ast_tools_support_u128_in_assert_layouts_generator branch from 8499052 to 919d133 Compare December 18, 2025 11:12
@github-actions github-actions bot added the A-parser Area - Parser label Dec 18, 2025
@overlookmotel overlookmotel marked this pull request as ready for review December 18, 2025 11:14
Copilot AI review requested due to automatic review settings December 18, 2025 11:14
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 support for u128 and i128 types in the AST generators. Previously, these 128-bit integer types caused panics because their alignment varied across Rust versions. Now that all supported Rust versions have consistent alignment of 16 for these types, they can be safely supported.

Key Changes:

  • Removed panic statements for u128/i128 types in the assert_layouts generator and replaced them with proper layout calculations
  • Added u128 deserialization logic to both raw_transfer and raw_transfer_lazy generators
  • Updated generated JavaScript with improved formatting comments

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
tasks/ast_tools/src/generators/assert_layouts.rs Replaced panic statements with proper Layout calculations for u128, i128, NonZeroU128, and NonZeroI128 types
tasks/ast_tools/src/generators/raw_transfer.rs Added u128 deserialization function and improved u64 formatting with clarifying comments
tasks/ast_tools/src/generators/raw_transfer_lazy.rs Added u128 deserialization function and improved u64 formatting with clarifying comments
napi/parser/src-js/generated/lazy/constructors.js Updated generated u64 constructor with clarifying comment for the 2^32 constant

Critical Issue Found: The constant used for 2^64 in the u128 deserialization logic is incorrect in both raw_transfer.rs and raw_transfer_lazy.rs. The value 18446744073709552000 should be 18446744073709551616 (a difference of 384), which will cause incorrect deserialization of u128 values.


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

@overlookmotel overlookmotel force-pushed the 12-18-fix_ast_tools_support_u128_in_assert_layouts_generator branch from 919d133 to 98dcb91 Compare December 18, 2025 11:21
@overlookmotel overlookmotel self-assigned this Dec 18, 2025
@overlookmotel overlookmotel added 0-merge Merge with Graphite Merge Queue and removed A-parser Area - Parser labels Dec 18, 2025
Copy link
Member Author

overlookmotel commented Dec 18, 2025

Merge activity

Previously `u128` was not supported in `assert_layouts` generator, because Rust changed the alignment of `u128` from 8 to 16 - and therefore the alignment depended on Rust version.

That change happened some time ago now, and all Rust versions above our MSRV have `u128` with alignment of 16. So we can now support `u128` (and also `i128`, `NonZeroU128`, `NonZeroI128`).

Also support `u128` in `raw_transfer` and `raw_transfer_lazy` generators.

This will help with making lexer tokens serializable (#17025), since `Token` contains a `u128`.
@graphite-app graphite-app bot force-pushed the 12-18-fix_ast_tools_support_u128_in_assert_layouts_generator branch from 98dcb91 to a92faf0 Compare December 18, 2025 11:58
@github-actions github-actions bot added the A-parser Area - Parser label Dec 18, 2025
@graphite-app graphite-app bot merged commit a92faf0 into main Dec 18, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 12-18-fix_ast_tools_support_u128_in_assert_layouts_generator branch December 18, 2025 12:05
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 18, 2025
overlookmotel added a commit that referenced this pull request Dec 19, 2025
### 🚀 Features

- d209c21 allocator: Add cap to FixedSizeAllocatorPool and block when
exhausted (#17023) (Cameron)
- fb2af91 allocator: Add bitset utils (#17042) (zhaoting zhou)
- c16082c tasks/compat_data: Integrate `node-compat-table` (#16831)
(Boshen)
- 5586823 span: Extract TS declaration file check to its own function
(#17037) (camchenry)
- 3d2b492 minifier: Fold iife arrow functions in call expressions
(#16477) (Armano)
- 67e9f9e codegen: Keep comments on the export specifiers (#16943)
(夕舞八弦)
- cb515fa parser: Improve error message for `yield` as identifier usage
(#16950) (sapphi-red)
- dcc856b parser: Add help for `new_dynamic_import` error (#16949)
(sapphi-red)
- c3c79f8 parser: Improve import attribute value error message (#16948)
(sapphi-red)
- 291b57b ast_tools: Generate TS declaration files for deserializer and
walk files (#16912) (camc314)
- 74eae13 minifier: Remove unused import specifiers (#16797) (camc314)

### 🐛 Bug Fixes

- fb9e193 linter: OOM problems with custom plugins (#17082)
(overlookmotel)
- e59132b parser/napi: Fix lazy deser (#17069) (overlookmotel)
- a92faf0 ast_tools: Support `u128` in `assert_layouts` generator
(#17050) (overlookmotel)
- 47b4c2f minifier/docs: Correct hyperlink path in OPTIMIZATIONS.md
(#16986) (GRK)
- 3002649 transformer/typescript: Remove unused import equals
declaration (#16776) (Dunqing)
- 5a2af88 regular_expression: Correct named capture group reference
error (#16952) (sapphi-red)

### ⚡ Performance

- b657bb6 allocator: Reduce time `Mutex` lock is held in
`FixedSizeAllocatorPool::get` (#17079) (overlookmotel)
- 1f3b19b ast: `#[ast]` macro use `#[repr(transparent)]` for
single-field structs (#17052) (overlookmotel)
- 225f229 parser: Use SmallVec for duplicate default export detection
(#16801) (camc314)

### 📚 Documentation

- a9c419f traverse: Update safety comments (#16944) (overlookmotel)

Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>
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 A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants