summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test.toc4
-rw-r--r--types.c15
2 files changed, 14 insertions, 5 deletions
diff --git a/test.toc b/test.toc
index 86d3b9f..3bebaf7 100644
--- a/test.toc
+++ b/test.toc
@@ -1,6 +1,6 @@
#include "std/io.toc";
-g ::= fn(modulator:: int, x : ..) int {
+g ::= fn(modulator:: int, x :: ..) int {
total := 0;
for e := x {
total += modulator * (e as int);
@@ -8,7 +8,7 @@ g ::= fn(modulator:: int, x : ..) int {
total
};
-f ::= fn(x : ..) int {
+f ::= fn(x :: ..) int {
g(2, x)
};
diff --git a/types.c b/types.c
index c1acac9..5480ec1 100644
--- a/types.c
+++ b/types.c
@@ -2191,15 +2191,24 @@ static Status types_expr(Typer *tr, Expression *e) {
VarArg *varargs = NULL;
arr_set_lena(&varargs, nvarargs, tr->allocr);
Declaration *varargs_param = arr_last(fn_copy->params);
+ DeclFlags is_const = varargs_param->flags & DECL_IS_CONST;
varargs_param->val.varargs = varargs;
for (int v = 0; v < (int)nvarargs; ++v) {
Expression *arg = &arg_exprs[v+order[nparams-1]];
VarArg *vararg = &varargs[v];
-
- if (varargs_param->flags & DECL_IS_CONST)
- vararg->val = arg->val;
+ if (is_const) {
+ Value val;
+ if (!eval_expr(tr->evalr, arg, &val))
+ return false;
+ arg->kind = EXPR_VAL;
+ arg->val = val;
+ copy_val(tr->allocr, &vararg->val, arg->val, &arg->type);
+ }
vararg->type = &arg->type;
}
+ if (is_const) {
+ varargs_param->flags |= DECL_FOUND_VAL;
+ }
}
}