From 235f74a8c9caf8d3b550d8cec164cf7f9d1444f6 Mon Sep 17 00:00:00 2001 From: agra Date: Sun, 14 Jun 2026 13:33:50 +0300 Subject: [PATCH] test(ffi-linkage): xfail example for extern data global (Phase 1.2c) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add examples/1225-ffi-extern-global.sx — '__stdinp : *void extern;' references libSystem's stdin pointer via the bare 'extern' modifier on a typed var decl (the extern-named counterpart of the #foreign global in examples/1205). Hand-authored snapshot expects the success output. RED: 1225 is the sole corpus failure (636 ran, 1 failed) — parse error, 'extern' after a type annotation is not yet accepted in the var-decl path. Phase 1.2d parses it and lowers the extern global. xfail commit per the cadence rule. --- current/CHECKPOINT-EXTERN-EXPORT.md | 3 +++ examples/1225-ffi-extern-global.sx | 15 +++++++++++++++ examples/expected/1225-ffi-extern-global.exit | 1 + examples/expected/1225-ffi-extern-global.stderr | 1 + examples/expected/1225-ffi-extern-global.stdout | 1 + 5 files changed, 21 insertions(+) create mode 100644 examples/1225-ffi-extern-global.sx create mode 100644 examples/expected/1225-ffi-extern-global.exit create mode 100644 examples/expected/1225-ffi-extern-global.stderr create mode 100644 examples/expected/1225-ffi-extern-global.stdout diff --git a/current/CHECKPOINT-EXTERN-EXPORT.md b/current/CHECKPOINT-EXTERN-EXPORT.md index 99f5b5e..b0442a2 100644 --- a/current/CHECKPOINT-EXTERN-EXPORT.md +++ b/current/CHECKPOINT-EXTERN-EXPORT.md @@ -80,6 +80,9 @@ historical carve-out — keep `issues/*.md` provenance, gate the live tree only. extern_name → declare under C name, map sx→C) and extends the dedupe guard to extern. 1224 green (`c_abs`→`abs`); 1223 unregressed. Suite green (635/443). `green` commit. extern_lib parsed+stored (lib linking stays the `#library` axis). +- (1.2c) Added `examples/1225-ffi-extern-global.sx` (`__stdinp : *void extern;`, + mirrors `#foreign` global 1205) + success snapshot. RED (636 ran, 1 failed — parse + error: var-decl `extern` not accepted). `xfail`; 1.2d greens it. ## Known issues - **Workflow hazard (1.2):** an editor format-on-save (or `zig fmt`) clobbered the diff --git a/examples/1225-ffi-extern-global.sx b/examples/1225-ffi-extern-global.sx new file mode 100644 index 0000000..7612c0c --- /dev/null +++ b/examples/1225-ffi-extern-global.sx @@ -0,0 +1,15 @@ +// extern data global (FFI-linkage stream, Phase 1.2): reference a symbol +// defined elsewhere (here libSystem's __stdinp) via the bare `extern` +// linkage modifier on a typed var decl — the extern-named counterpart of +// ` : #foreign;` (see examples/1205). The optional +// `extern [LIB] ["csym"]` tail mirrors the fn form; bare here (the sx name +// IS the C symbol, resolved against the default-linked libSystem). +#import "modules/std.sx"; + +__stdinp : *void extern; + +main :: () -> i32 { + addr_bits : u64 = xx @__stdinp; + print("stdin extern global non-null: {}\n", addr_bits != 0); + 0 +} diff --git a/examples/expected/1225-ffi-extern-global.exit b/examples/expected/1225-ffi-extern-global.exit new file mode 100644 index 0000000..573541a --- /dev/null +++ b/examples/expected/1225-ffi-extern-global.exit @@ -0,0 +1 @@ +0 diff --git a/examples/expected/1225-ffi-extern-global.stderr b/examples/expected/1225-ffi-extern-global.stderr new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/examples/expected/1225-ffi-extern-global.stderr @@ -0,0 +1 @@ + diff --git a/examples/expected/1225-ffi-extern-global.stdout b/examples/expected/1225-ffi-extern-global.stdout new file mode 100644 index 0000000..bd1a7bc --- /dev/null +++ b/examples/expected/1225-ffi-extern-global.stdout @@ -0,0 +1 @@ +stdin extern global non-null: true