Files
sx/examples/concurrency/1801-concurrency-naked-generic.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

23 lines
1014 B
Plaintext

// Stream B1 (fibers) — `abi(.naked)` on a GENERIC function emits a correct naked
// body (regression for an adversarial-review finding).
//
// A generic function is monomorphized through a different Function-creation path
// (lower/generic.zig) than a plain decl. That path originally left `is_naked`
// unset, so a generic `abi(.naked)` instance silently shipped a FRAMED body — it
// returned 42 but leaked the prologue's stack adjustment (the exact SP-in ≠
// SP-out corruption the `.naked` ABI exists to avoid). generic.zig (and the
// sibling pack-expansion path in pack.zig) now set `is_naked` and emit the
// asm-only naked body. This pins that: the monomorphized `answer__i64` is a
// proper naked function (no frame), returning 42. aarch64-pinned (the asm body
// is per-arch); runs end-to-end on a matching host, ir-only elsewhere.
answer :: ($T: Type) -> i64 abi(.naked) {
asm volatile {
#string A
mov x0, #42
ret
A
};
}
main :: () -> i64 { return answer(i64); }