bugfix(defs): Name macro-call modules by macro name and offset, not raw call text.#10197
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryMedium Risk Overview Semantic tests were added so repeated Reviewed by Cursor Bugbot for commit 4c314ab. Bugbot is set up for automated code reviews on this repo. Configure here. |
6076d33 to
fe17ea6
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on eytan-starkware and TomerStarkware).
crates/cairo-lang-semantic/src/items/macro_call_test.rs line 23 at r1 (raw file):
/// modules generated by item-level inline macro calls. fn test_macro_call_item_full_paths( inputs: &OrderedHashMap<String, String>,
i think you can use diagnostics to "expose" the actual path we provide.
fe17ea6 to
c2ab364
Compare
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware made 1 comment.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on orizi and TomerStarkware).
crates/cairo-lang-semantic/src/items/macro_call_test.rs line 23 at r1 (raw file):
Previously, orizi wrote…
i think you can use diagnostics to "expose" the actual path we provide.
Done.
c2ab364 to
9075a01
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9075a01. Configure here.
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 5 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).
9075a01 to
4c314ab
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).
|
Security scan complete — no issues detected. Generated by Claude Code |


Summary
Anonymous modules generated by item-level inline macro calls are now named after the invoked macro and disambiguated by the call-site byte offset in the file (e.g.,
make_pair_75) instead of using the full raw syntax text of the call as the module name.Type of change
Please check one:
Why is this change needed?
Previously, the name of the hidden module wrapping items produced by a top-level inline macro call was derived from the entire raw syntax text of the macro invocation, which produced unwieldy and fragile identifiers. When the same macro is invoked multiple times, each call needs a distinct, stable, and human-readable module name so that full paths of generated items (e.g., free functions) are predictable and debuggable.
What was the behavior or documentation before?
The anonymous macro-call module was named by calling
get_text_without_triviaon the entire syntax node of the macro call, yielding the raw invocation text as the module name.What is the behavior or documentation after?
The module is named
<macro_name>_<byte_offset>, where<macro_name>is the final identifier of the macro's path and<byte_offset>is the call's offset within the source file. For example, two calls tomake_pair!()at offsets 75 and 90 produce modules namedmake_pair_75andmake_pair_90, giving generated functions full paths liketest::make_pair_75::aandtest::make_pair_90::b. For macros invoked via a qualified path (e.g.,helpers::make_pair!()), only the final identifier is used.A new test file (
macro_call_test.rs) and accompanying test data (tests/macro_call) are added to verify full paths for: a single macro call, repeated macro calls producing distinct modules, and a macro invoked via a qualified path.Related issue or discussion (if any)
Additional context
The offset-based disambiguation ensures that two calls to the same macro always produce different module names without requiring any global counter or additional state.