Files
sx/examples/diagnostics/1110-diagnostics-autoref-compound-lvalue.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

21 lines
770 B
Plaintext

// Auto-ref of a COMPOUND lvalue (field access / index / deref) passed to a
// `*T` parameter must reference the REAL lvalue, not a copy. Regression: a
// field-access argument (e.g. `make_move(self.board, m)`) silently passed the
// address of a temporary copy, so mutations through the pointer were lost with
// no diagnostic. A plain local (`bump(x)`) already auto-ref'd; now compound
// lvalues do too. Expected: w.s.v == 42 (the real field was mutated).
#import "modules/std.sx";
S :: struct { v: i32; }
W :: struct { s: S; }
bump :: (p: *S) { p.v = p.v + 41; }
main :: () -> i32 {
w : W = .{ s = .{ v = 1 } };
bump(w.s); // field access, no `@` — auto-refs &w.s
print("w.s.v = {}\n", w.s.v); // 42, not 1
return 0;
}