From 1e12b8af8c5b4cb680341b976a065930f62725b5 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sat, 14 Dec 2019 19:09:12 -0500 Subject: fixed bug with inference --- test.toc | 17 ++++++++++------- types.c | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test.toc b/test.toc index e6ff4bd..b367305 100644 --- a/test.toc +++ b/test.toc @@ -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 diff --git a/types.c b/types.c index 3188692..a403e38 100644 --- a/types.c +++ b/types.c @@ -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); -- cgit v1.2.3