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

bugfix(semantic): Prevented doubled use self; diagnostic. - #10067

Merged
orizi merged 1 commit into
mainfrom
orizi/06-08-bugfix_semantic_prevented_doubled_use_self_diagnostic
Jun 8, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-08-bugfix_semantic_prevented_doubled_use_self_diagnostic

Conversation

@orizi

@orizi orizi commented Jun 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes a bug where use self; (a standalone self in a use path) was emitting two diagnostics instead of one. The fix reorders the logic in resolve_use_path so that the empty-path check occurs immediately after popping the self segment, before the non-multi-use check. This ensures that use self; reports only the UseSelfEmptyPath error and exits early, rather than also triggering UseSelfNonMulti. A test case is added to verify that use self; produces exactly one diagnostic.


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?

Previously, use self; would trigger two separate diagnostics: one for UseSelfEmptyPath and one for UseSelfNonMulti. Only the UseSelfEmptyPath error is appropriate here, since the path is empty and the non-multi check is redundant and misleading in this case.


What was the behavior or documentation before?

use self; produced two diagnostics: an error for using self in a non-multi-use path, and an error for self being used with an empty path.


What is the behavior or documentation after?

use self; produces a single diagnostic:

error[E2089]: `self` in `use` items is not allowed for empty path.
 --> lib.cairo:1:5
use self;
    ^^^^

Related issue or discussion (if any)

N/A


Additional context

N/A

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 8, 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 8, 2026 17:52
@cursor

cursor Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Small reordering of existing use-path validation in the semantic resolver; behavior for non-empty paths is unchanged and covered by existing tests.

Overview
Fixes duplicate diagnostics for standalone use self;, which previously reported both E2089 (UseSelfEmptyPath) and E2088 (UseSelfNonMulti).

In resolve_use_path, after stripping a trailing self segment, the resolver now checks for an empty path first and returns with UseSelfEmptyPath only. The non-multi-use check runs only when the path still has segments (e.g. use a::b::self; is unchanged). A semantic test asserts use self; emits a single E2089 diagnostic.

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

@orizi
orizi enabled auto-merge June 8, 2026 17:53

@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 8, 2026
Merged via the queue into main with commit af33022 Jun 8, 2026
54 checks passed
@orizi
orizi deleted the orizi/06-08-bugfix_semantic_prevented_doubled_use_self_diagnostic branch June 9, 2026 08:11
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.

3 participants