diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-11-20 12:27:29 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-11-20 12:27:29 -0500 |
commit | ce130e8da7f41400a9ff45b3d30d34930ce31feb (patch) | |
tree | 1898ede373d2adf7ad63928e92be7f20f5fcbec2 | |
parent | b905ea0f51cba69837643717182982dd93cd3f0d (diff) |
fixed problem with type params
-rw-r--r-- | copy.c | 8 | ||||
-rw-r--r-- | test.toc | 12 | ||||
-rw-r--r-- | types.c | 2 |
3 files changed, 13 insertions, 9 deletions
@@ -45,7 +45,7 @@ static void copy_val(Copier *c, Value *out, Value *in, Type *t) { } static void copy_type(Copier *c, Type *out, Type *in) { - assert(!(in->flags & TYPE_IS_RESOLVED)); + /* needs to handle resolved and unresolved types properly */ *out = *in; switch (in->kind) { case TYPE_BUILTIN: @@ -71,8 +71,10 @@ static void copy_type(Copier *c, Type *out, Type *in) { } } break; case TYPE_ARR: - out->arr.n_expr = allocr_malloc(c->allocr, sizeof *out->arr.n_expr); - copy_expr(c, out->arr.n_expr, in->arr.n_expr); + if (!(in->flags & TYPE_IS_RESOLVED)) { + out->arr.n_expr = allocr_malloc(c->allocr, sizeof *out->arr.n_expr); + copy_expr(c, out->arr.n_expr, in->arr.n_expr); + } out->arr.of = allocr_malloc(c->allocr, sizeof *out->arr.of); copy_type(c, out->arr.of, in->arr.of); break; @@ -1,7 +1,7 @@ -// puti @= fn(x: int) { -// #C("printf(\"%ld\\n\", (long)x); -// "); -// }; +puti @= fn(x: int) { + #C("printf(\"%ld\\n\", (long)x); +"); +}; // putf @= fn(x: float) { // #C("printf(\"%f\\n\", (double)x); // "); @@ -10,8 +10,8 @@ main @= fn() { - g(int); - g(); + puti(g(int)); + puti(g()); }; g @= fn(t @= int) int { @@ -1606,6 +1606,8 @@ static bool types_expr(Typer *tr, Expression *e) { break; } case EXPR_TYPE: + if (!type_resolve(tr, &e->typeval, e->where)) + return false; t->kind = TYPE_TYPE; break; case EXPR_VAL: |