From dd927c2e94a1375b5bc22632d46188f1288762a9 Mon Sep 17 00:00:00 2001 From: agra Date: Sun, 14 Jun 2026 15:37:25 +0300 Subject: [PATCH] test(ffi-linkage): xfail #foreign+postfix conflict diagnostic (Phase 4) --- .../1174-diagnostics-foreign-postfix-conflict.sx | 15 +++++++++++++++ ...1174-diagnostics-foreign-postfix-conflict.exit | 1 + ...74-diagnostics-foreign-postfix-conflict.stderr | 5 +++++ ...74-diagnostics-foreign-postfix-conflict.stdout | 1 + 4 files changed, 22 insertions(+) create mode 100644 examples/1174-diagnostics-foreign-postfix-conflict.sx create mode 100644 examples/expected/1174-diagnostics-foreign-postfix-conflict.exit create mode 100644 examples/expected/1174-diagnostics-foreign-postfix-conflict.stderr create mode 100644 examples/expected/1174-diagnostics-foreign-postfix-conflict.stdout diff --git a/examples/1174-diagnostics-foreign-postfix-conflict.sx b/examples/1174-diagnostics-foreign-postfix-conflict.sx new file mode 100644 index 0000000..41513f6 --- /dev/null +++ b/examples/1174-diagnostics-foreign-postfix-conflict.sx @@ -0,0 +1,15 @@ +// Phase 4 (FFI-linkage) interplay diagnostic: the prefix `#foreign` linkage +// modifier and the postfix `extern`/`export` keyword are two spellings of the +// same axis — combining them on one aggregate is contradictory (`#foreign` +// means import, `export` means define) or redundant (`#foreign … extern`). +// The parser rejects the combo at the postfix keyword instead of silently +// letting the postfix override `#foreign` (which previously surfaced as a +// confusing internal "compiler bug" diagnostic during class synthesis). +// +// Expected: one error caret on the `export` keyword; exit 1. + +C :: #foreign #objc_class("NSObject") export { + alloc :: () -> *C; +} + +main :: () -> i32 { 0 } diff --git a/examples/expected/1174-diagnostics-foreign-postfix-conflict.exit b/examples/expected/1174-diagnostics-foreign-postfix-conflict.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/examples/expected/1174-diagnostics-foreign-postfix-conflict.exit @@ -0,0 +1 @@ +1 diff --git a/examples/expected/1174-diagnostics-foreign-postfix-conflict.stderr b/examples/expected/1174-diagnostics-foreign-postfix-conflict.stderr new file mode 100644 index 0000000..2171764 --- /dev/null +++ b/examples/expected/1174-diagnostics-foreign-postfix-conflict.stderr @@ -0,0 +1,5 @@ +error: conflicting linkage: prefix '#foreign' cannot be combined with postfix 'export'; use either '#foreign' or postfix 'extern'/'export', not both + --> examples/1174-diagnostics-foreign-postfix-conflict.sx:11:39 + | +11 | C :: #foreign #objc_class("NSObject") export { + | ^^^^^^ diff --git a/examples/expected/1174-diagnostics-foreign-postfix-conflict.stdout b/examples/expected/1174-diagnostics-foreign-postfix-conflict.stdout new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/examples/expected/1174-diagnostics-foreign-postfix-conflict.stdout @@ -0,0 +1 @@ +