summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-12-14 19:09:12 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2019-12-14 19:09:12 -0500
commit1e12b8af8c5b4cb680341b976a065930f62725b5 (patch)
treea65de4a8da9640374b849459587d308f5f71f78d
parenteab1148f8db6b9400f13e574dfe4e174d6f52fad (diff)
fixed bug with inference
-rw-r--r--test.toc17
-rw-r--r--types.c1
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);