Sitelet https://github.com/starkware-libs/cairo/pull/10148
Skip to content

bugfix(semantic): Added diagnostic for use * in statement context. - #10148

Merged
orizi merged 1 commit into
mainfrom
orizi/06-22-bugfix_semantic_added_diagnostic_for_use_in_statement_context
Jun 23, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-22-bugfix_semantic_added_diagnostic_for_use_in_statement_context

Conversation

@orizi

@orizi orizi commented Jun 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Glob (*) use statements in statement position (e.g., use core::array::*; inside a function body) now produce a proper diagnostic error (E2075: Unsupported use item in statement) instead of being silently accepted or causing unexpected behavior.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

Glob use items inside statement position were not being caught and rejected. The existing logic only iterated over path leaves when processing use statements inside function bodies, but glob (*) paths are not leaves — they are star segments. This meant glob imports in statement position slipped through without a diagnostic, leading to incorrect behavior (regression tracked in #10142).


What was the behavior or documentation before?

A glob use statement such as use core::array::*; inside a function body was not reported as an error, even though glob use items are unsupported in statement position.


What is the behavior or documentation after?

A glob use statement inside a function body now correctly emits:

error[E2075]: Unsupported use item in statement.
 --> lib.cairo:2:22
    use core::array::*;
                     ^

Related issue or discussion (if any)

Fixes #10142.


Additional context

The fix introduces a call to get_all_path_stars alongside the existing get_all_path_leaves call, so that star segments in a use path are also checked and reported before leaf resolution is attempted.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi
orizi marked this pull request as ready for review June 22, 2026 11:44
@cursor

cursor Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Narrow diagnostic-only change in statement use processing; no module-level glob behavior change.

Overview
Statement-level use handling only walked path leaves, so glob segments like use core::array::*; were never rejected. The semantic pass now also walks star segments via get_all_path_stars and reports UnsupportedUseItemInStatement (E2075) on each *, before leaf resolution runs.

A regression test covers use core::array::*; inside a function (fixes #10142).

Reviewed by Cursor Bugbot for commit a5e4687. Bugbot is set up for automated code reviews on this repo. Configure here.

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit a0fc8f8 Jun 23, 2026
55 checks passed
@orizi
orizi deleted the orizi/06-22-bugfix_semantic_added_diagnostic_for_use_in_statement_context branch June 23, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Glob use inside fn body silently accepted with no effect

3 participants