fix(0123): wrong arg counts to fixed-arity fns error at the call site
checkCallArity compares the supplied count against the declared params (min = params without trailing defaults, max = params.len, unbounded past a variadic) at the five plain dispatch sites in lowerCall — bare selected-author + lazy, namespace alias-gate + qualified, struct method, ufcs. Pack / comptime / generic / #compiler / #builtin callees keep their own dispatch. The method/ufcs sites also gain the appendDefaultArgs fill the generic-instance leg already had, so trailing defaults work on dot-calls instead of emitting under-arity calls. lowerStmt's local fn_decl arm now registers a pointer into the AST node in fn_ast_map, not a stack temporary that aliased every later local fn.
This commit is contained in:
@@ -1,5 +1,27 @@
|
||||
# 0123 — wrong arg counts to fixed-arity fns reach LLVM emission
|
||||
|
||||
> **RESOLVED** (2026-06-12). Root cause: no dispatch path in `lowerCall`
|
||||
> ever compared the supplied arg count against the callee's declared
|
||||
> params (`coerceCallArgs` iterates `@min(args.len, params.len)`, so a
|
||||
> mismatch sailed through to the LLVM verifier). Fix: a shared
|
||||
> `checkCallArity` (src/ir/lower/call.zig) computes min (params without
|
||||
> trailing defaults) / max (`params.len`, unbounded past a variadic)
|
||||
> from the AST decl and rejects with a source-located diagnostic at the
|
||||
> five plain dispatch sites — bare selected-author + lazy, namespace
|
||||
> alias-gate + qualified, struct-method, ufcs. Pack / comptime / generic
|
||||
> / `#compiler` / `#builtin` callees are exempt (own dispatch). The
|
||||
> method/ufcs sites also gained the `appendDefaultArgs` fill the
|
||||
> generic-instance leg already had — trailing defaults on dot-calls
|
||||
> previously emitted under-arity calls (same verifier failure). Flushed
|
||||
> out en route: `lowerStmt`'s `.fn_decl => |fd| ... (&fd)` registered a
|
||||
> STACK address in `fn_ast_map`, so every local fn's map entry aliased
|
||||
> the most recently lowered one — pointer capture (`|*fd|`) fixes it.
|
||||
> Regressions: `examples/1167-diagnostics-call-arity-mismatch.sx`
|
||||
> (too many / too few, bare + stdlib + method + ufcs) and
|
||||
> `examples/0054-basic-dot-call-default-args.sx` (dot-call defaults,
|
||||
> variadic, `#caller_location`). Gates: zig build test 426/426, suite
|
||||
> 590/590 (fix in isolation), distribution repo 14/14.
|
||||
|
||||
## Symptom
|
||||
|
||||
Calling a fixed-arity function with the wrong number of arguments is
|
||||
|
||||
Reference in New Issue
Block a user