feature(semantic): Recognize Span<T> in fixed-size array patterns#9826
feature(semantic): Recognize Span<T> in fixed-size array patterns#9826ilyalesokhin-starkware merged 1 commit intomainfrom
Conversation
|
The error go a bit wierd, what do you think about doing something like: Code quote: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 219b96d. Configure here.
219b96d to
8741730
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on eytan-starkware and ilyalesokhin-starkware).
crates/cairo-lang-semantic/src/expr/test_data/let_statement line 156 at r1 (raw file):
Previously, ilyalesokhin-starkware wrote…
The error go a bit wierd, what do you think about doing something like:
#9825
lgtmed it.
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
@ilyalesokhin-starkware resolved 2 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
Teach the semantic layer to accept `[a, b, c]` patterns when matching on `Span<T>`, converting the pattern type to `@[T; N]`. The lowering layer reports an unsupported-type diagnostic for now; full lowering support will follow in a subsequent PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8741730 to
0e8eb8f
Compare
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
@ilyalesokhin-starkware made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ilyalesokhin-starkware).
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ilyalesokhin-starkware).
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on ilyalesokhin-starkware).


Teach the semantic layer to accept
[a, b, c]patterns when matching onSpan<T>, converting the pattern type to@[T; N]. The lowering layer reports an unsupported-type diagnostic for now; full lowering support will follow in a subsequent PR.Note
Medium Risk
Changes semantic pattern typing so
[a, b, ...]may type-check againstSpan<T>, which can affect type inference and diagnostics in match/let-else. Lowering explicitly rejects these patterns for now, so there’s limited runtime impact but potential for new compile-time behaviors/regressions.Overview
Enables fixed-size array patterns like
[a, b]to be semantically valid when the matched expression has typeSpan<T>, by treating the match as a fixed-size array of lengthN(with snapshot-wrapped element type) and updating tuple-like pattern validation logic accordingly.Lowering is not implemented yet: when matching on a struct type, lowering now detects
FixedSizeArraypatterns (Span destructures) and emits anUnsupportedMatchedTypematch diagnostic instead of attempting struct deconstruction. Diagnostics and test expectations were updated (notablyE2106) and new tests cover validSpandestructuring plus common error cases (non-Spanstructs,Array<T>vsSpan<T>, and trait inference failures).Reviewed by Cursor Bugbot for commit 0e8eb8f. Bugbot is set up for automated code reviews on this repo. Configure here.