Files
sx/examples/types/0165-types-nested-struct-field-assign.sx
agra 66bdc70bf1 test: group examples into per-category folders
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.
2026-06-21 14:41:34 +03:00

22 lines
857 B
Plaintext

// Writing through a nested struct field lvalue (`outer.inner.x = v`) and taking
// the address of a valid field both resolve the field pointer correctly: the
// lvalue-pointer path (lowerExprAsPtr) GEPs the matched field, never a silent
// field-0 default. Positive companion to the missing-field diagnostic (1145).
#import "modules/std.sx";
Inner :: struct { a: i64; b: i64; }
Outer :: struct { inner: Inner; tag: i64; }
bump :: (p: *i64) { p.* = p.* + 100; }
main :: () {
o := Outer.{ inner = Inner.{ a = 1, b = 2 }, tag = 9 };
o.inner.a = 11; // nested struct field store via lowerExprAsPtr
o.inner.b = 22;
o.tag = 33; // direct struct field store
print("a={} b={} tag={}\n", o.inner.a, o.inner.b, o.tag);
bump(@o.inner.a); // address-of a matched nested field
print("a2={}\n", o.inner.a);
}