You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
^^^^
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.
The reason will be displayed to describe this comment to others. Learn more.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment. Reviewable status: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
orizi
deleted the
orizi/06-08-bugfix_semantic_prevented_doubled_use_self_diagnostic
branch
June 9, 2026 08:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
use self;(a standaloneselfin a use path) was emitting two diagnostics instead of one. The fix reorders the logic inresolve_use_pathso that the empty-path check occurs immediately after popping theselfsegment, before the non-multi-use check. This ensures thatuse self;reports only theUseSelfEmptyPatherror and exits early, rather than also triggeringUseSelfNonMulti. A test case is added to verify thatuse self;produces exactly one diagnostic.Type of change
Please check one:
Why is this change needed?
Previously,
use self;would trigger two separate diagnostics: one forUseSelfEmptyPathand one forUseSelfNonMulti. Only theUseSelfEmptyPatherror 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 usingselfin a non-multi-use path, and an error forselfbeing used with an empty path.What is the behavior or documentation after?
use self;produces a single diagnostic:Related issue or discussion (if any)
N/A
Additional context
N/A