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).
35 lines
1.2 KiB
Plaintext
35 lines
1.2 KiB
Plaintext
// A positional literal `.{ a, b }` whose target is a TUPLE coerces each
|
|
// element to the tuple's per-position field type — so an optional field gets a
|
|
// properly wrapped `{T,i1}` value, an int element narrows/widens to a float
|
|
// field, etc.
|
|
//
|
|
// Regression (issue 0174): the positional struct-literal path coerced
|
|
// array/vector elements and struct fields but NOT tuple fields, so a bare
|
|
// `i64` was stored straight into a `{i64,i1}` optional slot — a present
|
|
// optional read back as absent.
|
|
#import "modules/std.sx";
|
|
|
|
main :: () {
|
|
// Optional + float fields.
|
|
t : (?i64, f64) = .{ 7, 3.0 };
|
|
print("{} {}\n", t.0 ?? -1, t.1); // 7 3.000000
|
|
|
|
// int -> float coercion on a tuple element.
|
|
u : (f64, i64) = .{ 3, 4 };
|
|
print("{} {}\n", u.0, u.1); // 3.000000 4
|
|
|
|
// Named tuple.
|
|
n : (x: ?i64, y: f64) = .{ 5, 2.5 };
|
|
print("{} {}\n", n.x ?? -1, n.y); // 5 2.500000
|
|
|
|
// Variable elements flowing into an optional tuple field.
|
|
a := 9;
|
|
b := 1.5;
|
|
v : (?i64, f64) = .{ a, b };
|
|
print("{} {}\n", v.0 ?? -1, v.1); // 9 1.500000
|
|
|
|
// A bare `null` element into an optional tuple field.
|
|
w : (?i64, i64) = .{ null, 8 };
|
|
print("{} {}\n", w.0 ?? -1, w.1); // -1 8
|
|
}
|