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

bugfix(semantic): Removed extra diagnostic for type mismatches on missing. - #10121

Merged
orizi merged 1 commit into
mainfrom
orizi/06-18-bugfix_semantic_removed_extra_diagnostic_for_type_mismatches_on_missing_
Jun 18, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-18-bugfix_semantic_removed_extra_diagnostic_for_type_mismatches_on_missing_

Conversation

@orizi

@orizi orizi commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When an impl constant references an unresolvable type (e.g., const X: Nonexistent = 0;), the compiler was previously emitting both a "Type not found" error and a spurious "WrongType" mismatch diagnostic. The type mismatch check in validate_impl_item_constant now skips reporting when either the expected or actual type is a missing (error sentinel) type, suppressing the cascading false 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?

When a type in an impl constant declaration could not be resolved, the compiler would report the legitimate "Type not found" error and then also emit a spurious "WrongType" diagnostic, because the missing type sentinel did not match the expected concrete type. This caused confusing double-error output for a single root cause.


What was the behavior or documentation before?

Given:

trait MyTrait {
    const X: u32;
}
impl MyImpl of MyTrait {
    const X: Nonexistent = 0;
}

The compiler emitted both a "Type not found" error for Nonexistent and a secondary "WrongType" mismatch error.


What is the behavior or documentation after?

The compiler now emits only the "Type not found" error, suppressing the cascading type-mismatch diagnostic when either type involved in the comparison is a missing/error sentinel type.


Related issue or discussion (if any)

N/A


Additional context

A new test case was added to trait_const to assert that only the resolution error is reported and no spurious type-mismatch diagnostic appears.

orizi commented Jun 18, 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 18, 2026 04:49
@cursor

cursor Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Narrow diagnostic-guard change in impl constant validation plus a regression test; no runtime or type-system behavior change.

Overview
Fixes cascading diagnostics when an impl constant’s declared type fails to resolve (e.g. const X: Nonexistent = 0).

In validate_impl_item_constant, the trait-vs-impl type check now skips WrongType if either the expected or actual type is a missing sentinel (is_missing), matching the pattern already used for impl function signatures. Users see only the root Type not found error.

A trait_const test asserts that case emits a single E0006 and no extra mismatch diagnostic.

Reviewed by Cursor Bugbot for commit dc8e6c9. 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 18, 2026
Merged via the queue into main with commit c81c58a Jun 18, 2026
55 checks passed
@orizi
orizi deleted the orizi/06-18-bugfix_semantic_removed_extra_diagnostic_for_type_mismatches_on_missing_ branch June 21, 2026 12:14
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