test(ffi-linkage): Phase 5.0 prereq — xfail extern same-name authors wrongly ambiguous
Two flat imports each declare `absval` via `extern libc "abs"` (the `extern` twin of example 0729's `#foreign` form). Like its #foreign twin, this must compile + run (prints 7), not error as an ambiguous bare-call collision. Today `isPlainFreeFn` / `isPlainFreeFnDecl` exclude a `#foreign` body but classify an empty-block `extern` fn as a plain free function, so the two extern authors ARE counted in the bare-call ambiguity verdict and the call errors. A third extern/#foreign divergence (after visibility + variadic) and a prerequisite for migrating the fn-decl `#foreign` path onto `extern`. 646 corpus (1230 xfail), 444 unit.
This commit is contained in:
21
examples/1230-ffi-extern-same-name-authors.sx
Normal file
21
examples/1230-ffi-extern-same-name-authors.sx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// Two flat FILE imports each declare the SAME libc symbol `absval` via the
|
||||||
|
// `extern` keyword (the linkage-keyword twin of example 0729's `#foreign`
|
||||||
|
// form). The bare-call resolver must NOT count extern authors when deciding
|
||||||
|
// ambiguity — they are external C symbols, never rerouted by the bare-call
|
||||||
|
// machinery, so the existing first-wins foreign/extern dispatch binds the
|
||||||
|
// call and a same-name extern collision compiles + runs (prints 7), it does
|
||||||
|
// NOT error as ambiguous.
|
||||||
|
//
|
||||||
|
// Regression (FFI-linkage Part B): `isPlainFreeFn` / `isPlainFreeFnDecl`
|
||||||
|
// excluded a `#foreign` body but classified an empty-block `extern` fn as a
|
||||||
|
// plain free function, so the two extern authors were wrongly counted as an
|
||||||
|
// ambiguous bare-call collision. Prerequisite for migrating the fn-decl
|
||||||
|
// `#foreign` path onto `extern`.
|
||||||
|
#import "modules/std.sx";
|
||||||
|
#import "1230-ffi-extern-same-name-authors/a.sx";
|
||||||
|
#import "1230-ffi-extern-same-name-authors/b.sx";
|
||||||
|
|
||||||
|
main :: () -> i32 {
|
||||||
|
print("absval = {}\n", absval(-7));
|
||||||
|
0
|
||||||
|
}
|
||||||
6
examples/1230-ffi-extern-same-name-authors/a.sx
Normal file
6
examples/1230-ffi-extern-same-name-authors/a.sx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// One of two flat authors of `absval`, an `extern` libc binding — the
|
||||||
|
// `extern` twin of example 0729's `#foreign libc "abs"`. A consumer
|
||||||
|
// flat-importing BOTH must NOT see this as an ambiguous bare-call
|
||||||
|
// collision: extern authors (external C symbols) are excluded from the
|
||||||
|
// bare-call ambiguity verdict, exactly like their `#foreign` twins.
|
||||||
|
absval :: (n: i32) -> i32 extern libc "abs";
|
||||||
2
examples/1230-ffi-extern-same-name-authors/b.sx
Normal file
2
examples/1230-ffi-extern-same-name-authors/b.sx
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// The second flat author of `absval` — the identical `extern` binding.
|
||||||
|
absval :: (n: i32) -> i32 extern libc "abs";
|
||||||
1
examples/expected/1230-ffi-extern-same-name-authors.exit
Normal file
1
examples/expected/1230-ffi-extern-same-name-authors.exit
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
absval = 7
|
||||||
Reference in New Issue
Block a user