Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
23 lines
803 B
Plaintext
23 lines
803 B
Plaintext
// Assigning a struct LITERAL to a named-struct member of a plain `union`.
|
|
// `u.b = .{ code = 9 }` types the literal as the union member's struct type
|
|
// `S` and stores it — the target type propagates to a union-member lvalue
|
|
// exactly as it does to a struct field.
|
|
//
|
|
// Regression (issue 0133): the literal used to lower as `.unresolved` (the
|
|
// target-type path only inspected struct fields, not union members) and trip
|
|
// the LLVM-emission tripwire in emitStructInit.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
S :: struct { code: i64; }
|
|
U :: union { a: i64; b: S; }
|
|
|
|
main :: () {
|
|
u : U = ---;
|
|
u.b = .{ code = 9 }; // union member <- struct literal
|
|
print("code={}\n", u.b.code); // 9
|
|
|
|
u.a = 5; // scalar member still works
|
|
print("a={}\n", u.a); // 5
|
|
}
|