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

fix(semantic): report every invalid associated-item constraint, not just the first - #10207

Merged
orizi merged 1 commit into
mainfrom
orizi/07-17-fix_semantic_report_every_invalid_associated-item_constraint_not_just_the_first
Jul 18, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/07-17-fix_semantic_report_every_invalid_associated-item_constraint_not_just_the_first

Conversation

@orizi

@orizi orizi commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When processing associated-item constraints on a generic parameter, a return statement caused the loop to exit early after encountering the first invalid associated type, silently dropping any subsequent constraint errors. Replacing return map with continue allows the loop to keep processing remaining constraints and emit a diagnostic for each invalid one.


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 generic bound included multiple invalid associated-item constraints (e.g., +MyTrait<T>[Bogus1: u8, Bogus2: u16]), only the first unknown associated type was reported. The early return prevented the remaining constraints from being validated, leaving subsequent errors silently ignored.


What was the behavior or documentation before?

Only the first invalid associated type in a constraint list would produce a diagnostic. Any further invalid constraints in the same bound were silently skipped.


What is the behavior or documentation after?

Every invalid associated type in a constraint list produces its own diagnostic. For example, both Bogus1 and Bogus2 in +MyTrait<T>[Bogus1: u8, Bogus2: u16] are now reported as unknown associated types.


Related issue or discussion (if any)

N/A


Additional context

A new test case was added to generics test data to verify that all invalid associated-item constraints are reported independently rather than stopping at the first failure.

…ust the first

While collecting a generic parameter's associated-item constraints, the
`NonTraitTypeConstrained` arm did `return map`, abandoning the rest of the
constraint list after the first bad one. So `+MyTrait<T>[Bogus1: u8, Bogus2: u16]`
reported E2189 only for `Bogus1` and silently dropped `Bogus2`.

Replace `return map` with `continue`, matching the sibling arm, so each
invalid constraint is diagnosed.

Adds an `expr/test_data/generics` golden (gated on the experimental
`associated_item_constraints` feature) asserting both `Bogus1` and `Bogus2`
are reported.
@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jul 17, 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 July 17, 2026 09:13
@cursor

cursor Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Diagnostic-only change in generic bound parsing; valid code paths are unchanged and scope is a single loop control fix plus a test.

Overview
Fixes incomplete diagnostics when an impl generic bound lists several invalid associated-item constraints (e.g. +MyTrait<T>[Bogus1: u8, Bogus2: u16]).

In impl_generic_param_semantic, encountering an unknown associated type used to return from the constraint loop, so only the first bad name got E2189 and later names were skipped. The handler now continues after reporting, so each bogus associated type is diagnosed.

A generics semantic test asserts both Bogus1 and Bogus2 are reported when associated_item_constraints is enabled.

Reviewed by Cursor Bugbot for commit 4f661ac. 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 Jul 18, 2026
Merged via the queue into main with commit 3f8a087 Jul 18, 2026
55 checks passed
@orizi
orizi deleted the orizi/07-17-fix_semantic_report_every_invalid_associated-item_constraint_not_just_the_first branch July 18, 2026 11:36
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