diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-12-14 19:09:12 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-12-14 19:09:12 -0500 |
commit | 1e12b8af8c5b4cb680341b976a065930f62725b5 (patch) | |
tree | a65de4a8da9640374b849459587d308f5f71f78d | |
parent | eab1148f8db6b9400f13e574dfe4e174d6f52fad (diff) |
fixed bug with inference
-rw-r--r-- | test.toc | 17 | ||||
-rw-r--r-- | types.c | 1 |
2 files changed, 11 insertions, 7 deletions
@@ -5,15 +5,18 @@ putf ::= fn(x: float) { #C("printf(\"%f\\n\", x)"); }; -f ::= fn(t::=, x :t) t { - x + 1 +f ::= fn(t::=, u ::=, x :t, y:u) t { + x + (y as t) }; -// test: fn(t::=int,u::=t,x:u)u +test ::= fn(t::=int,u::=t,x:u)u { + x*2 +}; main ::= fn() { - puti(f(13)); - puti(f(14)); - puti(f(15)); - putf(f(3.1)); + puti(f(13,15)); + puti(f(14,14.4)); + puti(f(15,13.1)); + putf(f(2.2,3.1)); + puti(test(5)); };
\ No newline at end of file @@ -1331,6 +1331,7 @@ static bool types_expr(Typer *tr, Expression *e) { arg_exprs[i].type = table_index_type.tuple[i+1] = param_types[i] = param->type; arg_exprs[i].val = table_index.tuple[i+1] = param->val; params_set[i] = true; + ++i; continue; } assert(param->flags & DECL_HAS_EXPR); |