summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eval.c2
-rw-r--r--test.toc15
-rw-r--r--types.c4
3 files changed, 12 insertions, 9 deletions
diff --git a/eval.c b/eval.c
index d8b66a7..4a3e1a8 100644
--- a/eval.c
+++ b/eval.c
@@ -1450,7 +1450,7 @@ static Status eval_expr(Evaluator *ev, Expression *e, Value *v) {
bool multiple_idents = arr_len(p->idents) > 1;
bool is_tuple = p->type.kind == TYPE_TUPLE;
if (type_is_builtin(&p->type, BUILTIN_VARARGS)) {
- Expression *args_end = arg + nargs;
+ Expression *args_end = e->call.arg_exprs + nargs;
/* set varargs */
pval->varargs = NULL;
for (; arg != args_end; ++arg) {
diff --git a/test.toc b/test.toc
index c4ab3d9..21cd2c0 100644
--- a/test.toc
+++ b/test.toc
@@ -2,8 +2,8 @@
g ::= fn(modulator: int, x : ..) int {
total := 0;
- for e, i := x {
- total += modulator * i * (e as int);
+ for e := x {
+ total += modulator * (e as int);
}
total
};
@@ -13,14 +13,15 @@ f ::= fn(x : ..) int {
};
main ::= fn() {
- puti(f(5));
+ puti(f(5));
- puti(f(5,6));
+ puti(f(5,6));
- puti(f(1,2,3));
-
- puti(f(1,1,1,1));
+ puti(f(1,2,3));
+ puti(f(1,1,1,1));
+
+ puti(f());
};
main(); \ No newline at end of file
diff --git a/types.c b/types.c
index b57b7a5..2e02b49 100644
--- a/types.c
+++ b/types.c
@@ -1217,7 +1217,9 @@ static Status call_arg_param_order(FnExpr *fn, Type *fn_type, Argument *args, Lo
arr_foreach(fn->params, Declaration, decl) {
arr_foreach(decl->idents, Identifier, ident) {
if (order[param_idx] == -1) {
- if (!(decl->flags & DECL_HAS_EXPR) && !(decl->flags & DECL_INFER)) {
+ if (type_is_builtin(&decl->type, BUILTIN_VARARGS)) {
+ order[param_idx] = (I16)nargs;
+ } else if (!(decl->flags & DECL_HAS_EXPR) && !(decl->flags & DECL_INFER)) {
char *s = ident_to_str(*ident);
err_print(where, "Parameter #%lu (%s) was not set in function call.", param_idx+1, s);
free(s);