Files
sx/examples/1167-diagnostics-call-arity-mismatch.sx
agra 7f2b8b5cde 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.
2026-06-12 01:42:59 +03:00

27 lines
917 B
Plaintext

// Wrong argument counts to fixed-arity functions are rejected at the call
// site — bare calls, flat-imported stdlib fns, method dot-calls, and ufcs
// dot-calls — instead of reaching LLVM verification ("Incorrect number of
// arguments passed to called function!").
// Regression (issue 0123).
#import "modules/std.sx";
add2 :: (a: s64, b: s64) -> s64 { return a + b; }
Point :: struct {
x: s64;
scaled :: (self: Point, k: s64) -> s64 { return self.x * k; }
}
bump :: ufcs (p: Point, by: s64) -> s64 { return p.x + by; }
main :: () -> s32 {
_ = add2(1, 2, 3); // plain bare call, too many
_ = add2(1); // plain bare call, too few
_ = concat("a", "b", "c"); // flat-imported stdlib fn, too many
p := Point.{ x = 5 };
_ = p.scaled(2, 9); // method dot-call, too many
_ = p.bump(1, 2); // ufcs dot-call, too many
return 0;
}