summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test.toc2
-rw-r--r--types.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/test.toc b/test.toc
index 72282d4..3ea56d1 100644
--- a/test.toc
+++ b/test.toc
@@ -3,5 +3,5 @@ f ::= fn(y:f64=19.2) {
};
main ::= fn() {
- f();
+ f(13);
};
diff --git a/types.c b/types.c
index 5a2c946..a65d8d6 100644
--- a/types.c
+++ b/types.c
@@ -249,6 +249,13 @@ static bool type_of_fn(Typer *tr, FnExpr *f, Location where, Type *t, U16 flags)
}
param->expr.kind = EXPR_VAL;
param->expr.val = val;
+ if (param->expr.type.flags & TYPE_IS_FLEXIBLE) {
+ /* cast to the annotated type, if one exists */
+ if (param->flags & DECL_ANNOTATES_TYPE) {
+ val_cast(&param->expr.val, &param->expr.type, &param->expr.val, &param->type);
+ param->expr.type = param->type;
+ }
+ }
}
}
}
@@ -1189,7 +1196,6 @@ static bool types_expr(Typer *tr, Expression *e) {
if (should_be_evald && params_set[i]) {
Expression *expr = &arg_exprs[i];
-
Value *arg_val = typer_arr_add(tr, &table_index.tuple);
if (!eval_expr(tr->evalr, expr, arg_val)) {
if (tr->evalr->enabled) {
@@ -1205,7 +1211,6 @@ static bool types_expr(Typer *tr, Expression *e) {
arg_exprs[i].flags = EXPR_FOUND_TYPE;
copy_val(tr->allocr, &arg_exprs[i].val, arg_val, type);
arg_exprs[i].val = *arg_val;
- arg_exprs[i].type = *type;
copy_val(tr->allocr, &param_decl->val, arg_val, type);
param_decl->flags |= DECL_FOUND_VAL;