fix: literal element typing — typed-array null element, tuple coercion, positional var element (0173-0175)
0173: resolveArrayLiteralType gained no arm for [N]T/[]T heads, so a
([2]?i64).[...] head lost its ?i64 element type and a bare null reached
LLVM as const_null(.unresolved). Route structural heads through
resolveTypeWithBindings; validate an undefined element name in the head
via UnknownTypeChecker (semantic_diagnostics.zig) instead of a silent
empty-struct stub (no-silent-fallback).
0174: positional .{...} against a TUPLE target now coerces each element
to TupleInfo.fields[i] (was neither struct nor array, so uncoerced).
0175: a positional struct literal with a bare-variable element was
misclassified as a named shorthand (parser puns .{x} -> x=x), zeroing
the fields. has_names now consults the struct definition to reclassify a
punned non-field name as positional; positional coercion uses the
lowered value's real getRefType.
Regressions: optionals/0914, types/0199, types/0200, diagnostics/1196.
Verified by 4 adversarial reviews; suite 784/0. Filed adjacent bug 0176
(protocol-typed struct field method call aborts).
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
# 0174 — positional literal for a TUPLE target does not coerce elements (same corruption class as 0168)
|
||||
|
||||
> **RESOLVED.** `lowerStructLiteral`'s positional branch coerced struct fields
|
||||
> and array/vector elements but not TUPLE targets (a tuple is neither — empty
|
||||
> `struct_fields`, `.unresolved` `array_elem_ty`), so a bare element was stored
|
||||
> raw into the field slot (a `{T,i1}` optional read back absent). Fix
|
||||
> (`src/ir/lower/expr.zig`): compute `tuple_fields` from `TupleInfo.fields` and
|
||||
> fold it into a unified `elem_target` (`struct_fields[i].ty` → `tuple_fields[i]`
|
||||
> → `array_elem_ty`) that steers per-element `target_type` and drives
|
||||
> `coerceToType`. Verified across optional/int→float/protocol/slice/enum/nested
|
||||
> tuple elements + named tuples by 4 adversarial reviews. Regression:
|
||||
> `examples/types/0199-types-tuple-positional-optional-element.sx`.
|
||||
|
||||
## Symptom
|
||||
|
||||
A positional literal `.{ a, b }` whose target is a TUPLE does not coerce its
|
||||
|
||||
Reference in New Issue
Block a user