feat(ffi-linkage)!: Phase 8.1 — parser hard-rejects #foreign (cutover)

The prefix #foreign linkage directive is removed. All four parse sites
(const-with-type, data global, fn body, runtime-class prefix) now reject it with
a migration message ('#foreign has been removed; use the postfix extern (import) /
export (define) linkage keyword instead'); added a span-aware failAt for the
runtime-class case (the lookahead consumes the token before the reject decision).
Greens the Phase 8.0 xfail 1176.

- Deleted obsolete tests: 1174 (#foreign+postfix conflict — unreachable now that
  #foreign alone is rejected) and 1620 (#foreign nosuchunit lib-ref — superseded by
  the extern twin 1231). Their assertions tested #foreign-specific behavior.
- Removed the GATE A→B unit test + lowerSrcToIr helper (lower.test.zig): it locked
  #foreign ≡ extern through the migration; with #foreign gone there is nothing to
  compare. Converted the in-source 'parse void function with foreign body' parser
  test to the surviving postfix 'extern' spelling (identical resulting AST).
- specs.md + readme.md drop #foreign; document extern/export as the sole C-linkage
  surface.

extern_export in parseFnDecl is now const (the fn-body arm that mutated it is gone).
Suite green (646 corpus / 444 unit, 0 failed). NOTE: comment-only #foreign in
examples + issues/*.md prose + internal foreign_* identifiers remain for Phase 9
(now unblocked: Decision 6 = purge everything).
This commit is contained in:
agra
2026-06-15 08:06:05 +03:00
parent 8180faf839
commit 3811311e12
12 changed files with 69 additions and 340 deletions

View File

@@ -1,5 +0,0 @@
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 {
| ^^^^^^

View File

@@ -1,5 +0,0 @@
error: extern library 'nosuchunit' is not declared; expected a #library constant or a named '#import c' unit
--> examples/1620-cimport-foreign-ref-unvalidated.sx:12:1
|
12 | ref_answer :: () -> i32 #foreign nosuchunit "ref_answer";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^