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
examples/expected/0054-basic-dot-call-default-args.exit
Normal file
1
examples/expected/0054-basic-dot-call-default-args.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
10
|
||||
15
|
||||
15
|
||||
6
|
||||
0
|
||||
6
|
||||
true
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,29 @@
|
||||
error: 'add2' expects 2 arguments, but 3 were given
|
||||
--> examples/1167-diagnostics-call-arity-mismatch.sx:19:9
|
||||
|
|
||||
19 | _ = add2(1, 2, 3); // plain bare call, too many
|
||||
| ^^^^
|
||||
|
||||
error: 'add2' expects 2 arguments, but 1 was given
|
||||
--> examples/1167-diagnostics-call-arity-mismatch.sx:20:9
|
||||
|
|
||||
20 | _ = add2(1); // plain bare call, too few
|
||||
| ^^^^
|
||||
|
||||
error: 'concat' expects 2 arguments, but 3 were given
|
||||
--> examples/1167-diagnostics-call-arity-mismatch.sx:21:9
|
||||
|
|
||||
21 | _ = concat("a", "b", "c"); // flat-imported stdlib fn, too many
|
||||
| ^^^^^^
|
||||
|
||||
error: 'Point.scaled' expects 1 argument, but 2 were given
|
||||
--> examples/1167-diagnostics-call-arity-mismatch.sx:23:9
|
||||
|
|
||||
23 | _ = p.scaled(2, 9); // method dot-call, too many
|
||||
| ^^^^^^^^
|
||||
|
||||
error: 'bump' expects 1 argument, but 2 were given
|
||||
--> examples/1167-diagnostics-call-arity-mismatch.sx:24:9
|
||||
|
|
||||
24 | _ = p.bump(1, 2); // ufcs dot-call, too many
|
||||
| ^^^^^^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user