fixes issue-9896: convert ICE at db.rs:370 into a clean Maybe::Err#9897
fixes issue-9896: convert ICE at db.rs:370 into a clean Maybe::Err#9897anon-researchers-123 wants to merge 1 commit into
Conversation
PR SummaryMedium Risk Overview Adds regression coverage in Reviewed by Cursor Bugbot for commit 910e209. Bugbot is set up for automated code reviews on this repo. Configure here. |
orizi
left a comment
There was a problem hiding this comment.
@orizi made 1 comment.
Reviewable status: 0 of 8 files reviewed, 1 unresolved discussion (waiting on anon-researchers-123).
a discussion (no related file):
this will not prevent the crash - but it would make it much harder to actually find.
and again - missing an actual test showing crashed before, not crashing now.
…rkware-libs#9896) `add_type_based_diagnostics` previously fired E2053 only when the expression's *top-level* type was `Array<ZST>`. `arr.span()` on a fixed-size array whose element type is zero-sized produces a `Span<U>` whose offending `Array<U>` is buried under struct + snapshot layers, so the surface check missed it and the program reached sierra-gen, which panicked in `db::get_type_info` with `Could not specialize type`. Walk the type structurally — into struct members, enum variants, tuple items, snapshots, fixed-size-array elements, and closure captures — and report the existing `ArrayOfZeroSizedElements` (E2053) when an `Array<T>` with zero-sized `T` appears at any depth. The panic at `db.rs:370` is left in place as a true-ICE tripwire so that any remaining specialization gap stays findable. Adds a regression test under `expr/test_data/fixed_size_array` that asserts E2053 on `[U; 2].span()` (failed prior to this change since no diagnostic was emitted), and a positive test that `[u32; 2].span()` still type-checks cleanly.
f327483 to
910e209
Compare
Fixes #9896
get_type_infoincairo-lang-sierra-generator/src/db.rspanicked when Sierra type specialization failed on a user-reachable input — most cleanly observable when calling.span()on a fixed-size array of a zero-sized type. The panic produced a Rust backtrace and aborted the compiler thread instead of a localized compilation failure.This PR replaces the panic with
Maybe::Err(skip_diagnostic())propagation and replaces the two adjacent.unwrap()calls intypes::get_concrete_long_type_id'sSnapshotarm with?, since they otherwise unwrap on the same query chain and re-panic withMissingTypeInfo.Before (unpatched):
After (this PR):
The compiler exits with a non-zero status; no Rust panic, no backtrace at
db.rs:370. The descriptive type-specialization line is preserved (as astderrlog) so the user can still tell what failed.Related code: