Conversation
…xes; error on typed literals in consteval_int and test attrs.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryMedium Risk Overview Tightens validation in plugin/test utilities: Reviewed by Cursor Bugbot for commit f591340. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 6 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Replaces
numeric_value_and_suffixreturningOption<(BigInt, Option<SmolStrId>)>with a direct(BigInt, Option<SmolStrId>)return type. The new implementation scans_-separated segments from right to left, finding the longest valid numeric prefix and treating the remainder as the suffix. This correctly handles compound suffixes like1_u32_u8(returning value1with suffix"u32_u8") and ambiguous radix cases like0x1_f32(parsed as hex0x1F32with no suffix). Malformed literals such as0x_u32return(BigInt::ZERO, Some(full_token_text))as a sentinel.Callers that previously used
.unwrap_or_default()now receive the value directly and checksuffix.is_some()to detect errors. Theconsteval_intmacro andavailable_gastest attribute now emit explicit diagnostics when a typed (suffixed) literal is used where only plain integers are valid.Type of change
Please check one:
Why is this change needed?
The previous
rsplit_once('_')approach only split at the last_, so compound suffixes like1_u32_u8were mishandled —u32_u8was not recognized as a suffix, and the numeric parse would silently fail or return a wrong value viaunwrap_or_default(). Additionally, callers that usedunwrap_or_default()would silently swallow parse failures rather than surfacing them as diagnostics.What was the behavior or documentation before?
numeric_value_and_suffixreturnedOption<(BigInt, Option<SmolStrId>)>, splitting only at the rightmost_. Compound suffixes like1_u32_u8were not correctly identified. Callers used.unwrap_or_default(), silently producing0on failure. Theconsteval_intmacro and gas-value extraction did not emit diagnostics for typed literals.What is the behavior or documentation after?
numeric_value_and_suffixreturns(BigInt, Option<SmolStrId>)directly, scanning from right to left across all_boundaries to find the longest valid numeric prefix. Compound suffixes are correctly extracted. Theconsteval_intmacro emits"Literals with suffix are not supported in consteval_int macro"andavailable_gasemits"Literals with suffix are not supported as gas values"when a suffixed literal is encountered.Related issue or discussion (if any)
Fixes #9926
Additional context
New test cases cover
1_u32_u8and-1_u32_u8for compound suffixes in literal parsing, andconsteval_int!(1_u32)/consteval_int!(1_u32 + 2)for typed literals inside theconsteval_intmacro.