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

bugfix(semantic): Fixed suggested crate:: context paths. - #10044

Merged
orizi merged 1 commit into
mainfrom
orizi/06-07-bugfix_semantic_fixed_suggested_crate_context_paths
Jun 7, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-07-bugfix_semantic_fixed_suggested_crate_context_paths

Conversation

@orizi

@orizi orizi commented Jun 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes a bug where the crate:: path prefix was incorrectly double-encoding the crate name. When resolving a path via the crate root, the crate name was being included in path_items in addition to the ViaCrate kind prefix, resulting in paths like crate::my_crate::module::Item instead of the correct crate::module::Item. The fix removes the crate name from path_items before constructing the ItemAccessInfo when the owning crate matches the context module's crate.

A regression test was added to verify that ambiguous method call diagnostics using crate:: paths display the correct path format (e.g., crate::provider1::T::foo rather than a double-encoded variant).


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?

When two traits were imported via use crate::provider::* glob imports and an ambiguous method call occurred, the diagnostic message was generating malformed paths that included the crate name twice — once from path_items and once implicitly from the ViaCrate kind prefix.


What was the behavior or documentation before?

Ambiguous method call diagnostics for items resolved via crate:: would produce incorrectly formed paths, including the crate name redundantly alongside the crate:: prefix.


What is the behavior or documentation after?

Ambiguous method call diagnostics correctly display paths in the form crate::provider1::T::foo and crate::provider2::T::foo, without duplicating the crate name.


Related issue or discussion (if any)

None specified.


Additional context

None.

orizi commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

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

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

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

cursor Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Small, localized change to diagnostic path formatting in the semantic crate; behavior only affects how same-crate crate:: paths are displayed, not name resolution.

Overview
Fixes contextualized paths for same-crate items when the access kind is ViaCrate. The ancestor list from ancestors() ends at the crate root, but rendered paths already use the crate:: prefix, so diagnostics and suggestions were incorrectly including the crate name (e.g. double-encoding the crate in the path).

When the item’s owning crate matches the context module’s crate, get_contextualized_path now pop()s the final crate segment from path_items before building ItemAccessInfo, so strings like crate::provider1::T::foo are emitted instead of paths that repeat the crate name.

Adds a path diagnostics test for ambiguous trait method calls under use crate::provider*::*, locking in the expected crate::provider1::T::foo / crate::provider2::T::foo wording.

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

@eytan-starkware eytan-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:lgtm:

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

@orizi
orizi added this pull request to the merge queue Jun 7, 2026
Merged via the queue into main with commit 0dd4cbc Jun 7, 2026
54 checks passed
@orizi
orizi deleted the orizi/06-07-bugfix_semantic_fixed_suggested_crate_context_paths branch June 7, 2026 11:25
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