test(ffi-linkage): xfail example for extern fn binding (Phase 1.0b)

Add examples/1223-ffi-extern-fn.sx — binds libc 'abs' via bare 'extern'
(sx name = C symbol, no rename). Hand-authored expected/ captures the
SUCCESS output (abs(-7)=7 / abs(42)=42, exit 0).

RED: 1223 is the sole corpus failure (634 ran, 1 failed) — it parses
then errors at sema ('body produces no value') because lowering does
not yet route extern fns through declareExtern. Phase 1.1 wires the
lowering and turns this green.

xfail commit per the cadence rule (no commit both adds a test and makes
it pass).
This commit is contained in:
agra
2026-06-14 13:06:54 +03:00
parent df6b675e67
commit 78e304f552
5 changed files with 43 additions and 21 deletions

View File

@@ -0,0 +1,14 @@
// extern function binding (FFI-linkage stream, Phase 1): bind libc's `abs`
// directly via the bare `extern` linkage modifier — no `#foreign`, no
// `#library`. `extern` ⇒ external linkage + C ABI + no sx ctx; the symbol
// resolves against the default-linked libc at link time. The sx name `abs`
// IS the C symbol (no rename — the `extern LIB "csym"` forms land in 1.2).
#import "modules/std.sx";
abs :: (n: i32) -> i32 extern;
main :: () -> i32 {
print("abs(-7) = {}\n", abs(xx -7));
print("abs(42) = {}\n", abs(xx 42));
0
}

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,2 @@
abs(-7) = 7
abs(42) = 42