diff options
-rw-r--r-- | infer.c | 7 | ||||
-rw-r--r-- | test.toc | 7 | ||||
-rw-r--r-- | types.c | 4 |
3 files changed, 9 insertions, 9 deletions
@@ -23,18 +23,18 @@ static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Identi break; case EXPR_CALL: { if (to->kind != EXPR_CALL) return true; /* give up */ - puts("wow call"); Argument *m_args = match->call.args; Expression *t_args = to->call.arg_exprs; size_t nargs = arr_len(m_args); U16 *order = NULL; Expression *f = match->call.fn; - IdentDecl *idecl = ident_decl(f->ident); bool is_direct_fn = idecl && idecl->kind == IDECL_DECL && (idecl->decl->flags & DECL_HAS_EXPR) && idecl->decl->expr.kind == EXPR_FN; if (is_direct_fn) { - FnExpr *fn_decl = idecl->decl->expr.fn; + if (!types_expr(tr, f)) + return false; + FnExpr *fn_decl = idecl->decl->expr.fn; if (!call_arg_param_order(tr->allocr, fn_decl, idecl->decl->where, &f->type, m_args, match->where, &order)) return false; } @@ -109,7 +109,6 @@ static bool infer_from_type(Typer *tr, Type *match, Type *to, Identifier *idents } break; case TYPE_EXPR: { Expression *to_expr = to->was_expr; - print_type(to); Expression e = {0}; if (!to_expr) { to_expr = &e; @@ -7,11 +7,12 @@ putf ::= fn(x: float) { t ::= fn(a:: Type) Type {a}; -f ::= fn(b::=, a:t(b)) int{ -3 +f ::= fn(b::=, u::=, a:t(b), x:t(u)) int{ +((3 as b) as u) as int }; main ::= fn() { x : t(int) = 3; - f(x); + y : t(float) = 3.4; + f(x,y); };
\ No newline at end of file @@ -501,11 +501,11 @@ static bool type_resolve(Typer *tr, Type *t, Location where) { Value typeval; if (!types_expr(tr, t->expr)) return false; - print_expr(t->expr); - t->was_expr = t->expr; + Expression *expr = t->expr; if (!eval_expr(tr->evalr, t->expr, &typeval)) return false; *t = *typeval.type; + t->was_expr = expr; assert(t->flags & TYPE_IS_RESOLVED); } break; case TYPE_UNKNOWN: |