refactor(ffi-linkage): Phase 9.1d — eliminate the foreign_expr AST node

The last linkage-family 'foreign' carrier. Migrated c_import.zig auto-synthesis
(#import c {#include}) to build the extern shape (empty-block body + extern_export
= .extern_) instead of a foreign_expr body — the Phase 5.0 fn-body flip applied to
auto-synth. With nothing left building it, deleted the foreign_expr union variant +
ForeignExpr struct (ast.zig) and every reader: the dead-arm switch cases (sema,
resolver, generic, call, semantic_diagnostics, lsp), the coalescing reads in
decl.zig (is_foreign local, cc/rename/dedup/variadic/visibility gates) + pack.zig,
and checkForeignRefs (now reads extern_lib only). 9.1 LINKAGE PURGE COMPLETE — all
that remains in src/ is the runtime-class family (9.2) + comments. Snapshot-neutral
(the #import c examples 1215/1216/1217 + sqlite 1624 exercise the synth path); suite
green (646 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 08:54:56 +03:00
parent 98264b8640
commit 7ffdc7d2a2
10 changed files with 55 additions and 88 deletions

View File

@@ -296,12 +296,12 @@ pub fn lowerVariadicArgs(self: *Lowering, param_name: []const u8, call_args: []c
/// Detects variadic params in the function decl, packs remaining args into a typed slice,
/// and replaces the args list with [fixed_args..., slice_ref].
pub fn packVariadicCallArgs(self: *Lowering, fd: *const ast.FnDecl, c: *const ast.Call, args: *std.ArrayList(Ref)) void {
// A lib-less C-import variadic — `#foreign` (foreign_expr body) OR the new
// A lib-less C-import variadic via the `extern` keyword (or `#import c`
// `extern` keyword — uses the C calling convention's `...` tail: extras are
// passed through directly with default argument promotion (handled at the
// call site), not packed into an sx slice. Mirrors the `is_variadic` drop
// in `declareFunction`.
if ((fd.body.data == .foreign_expr or fd.extern_export == .extern_) and
if ((fd.extern_export == .extern_) and
fd.params.len > 0 and fd.params[fd.params.len - 1].is_variadic)
{
return;