fix(lower): diagnose .* on a non-pointer instead of codegen panic
`lowerDerefExpr` left the deref's result type `.unresolved` when the
operand wasn't a pointer (e.g. a stale `value.*` after a parameter
changed from `*T` to `T`), and emitted the `.deref` anyway. That
unresolved type slipped through to emit_llvm's "unresolved type reached
LLVM emission" panic with no source location.
Now it emits a clean diagnostic at the deref site
("cannot dereference with `.*`: 'T' is not a pointer") and recovers.
Regression: examples/254-deref-non-pointer-reject.sx.
This commit is contained in:
14
examples/254-deref-non-pointer-reject.sx
Normal file
14
examples/254-deref-non-pointer-reject.sx
Normal file
@@ -0,0 +1,14 @@
|
||||
// `.*` on a non-pointer must be a clean compile diagnostic, NOT a codegen
|
||||
// panic. Regression: a stale `value.*` (e.g. after a parameter changed from
|
||||
// `*T` to `T` by value) used to lower a `.deref` with an `.unresolved` result
|
||||
// type, which slipped through to emit_llvm's "unresolved type reached LLVM
|
||||
// emission" panic with no source location. `lowerDerefExpr` now diagnoses it.
|
||||
// Expected: a clean error pointing at the deref; exit 1.
|
||||
|
||||
Point :: struct { x: s32; y: s32; }
|
||||
|
||||
main :: () -> s32 {
|
||||
p : Point = .{ x = 3, y = 4 };
|
||||
q := p.*; // ERROR: `p` is a Point value, not a pointer
|
||||
return q.x;
|
||||
}
|
||||
Reference in New Issue
Block a user