summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c2
-rw-r--r--test.toc20
-rw-r--r--types.c14
3 files changed, 25 insertions, 11 deletions
diff --git a/main.c b/main.c
index 66b7c7f..eae8c1a 100644
--- a/main.c
+++ b/main.c
@@ -18,8 +18,6 @@
/*
TODO:
-remember to free order
----
see infer.c "is resolved_to necessary" (now that ident system has changed)
replace is_reference in type_resolve_ with system for checking if type is
circularly dependent in a bad way, with compiler_sizeof
diff --git a/test.toc b/test.toc
index e5ca1fa..11e2a24 100644
--- a/test.toc
+++ b/test.toc
@@ -1,11 +1,19 @@
-io ::= nms {
-#include "std/io.toc";
+// io ::= nms {
+// #include "std/io.toc";
+// };
+
+// p ::= struct(x::Type,y::=3) {
+// b:int;
+// };
+
+foo ::= fn(x::int) Type {
+ [x]int
};
-p ::= struct(x::Type,y::=3) {
- b:int;
+z ::= fn(a::=,b:foo(a)) {
};
+
main ::= fn() {
-z:p(int);
-x:[z.y]z.x;
+ n:foo(3);
+ z(n);
}; \ No newline at end of file
diff --git a/types.c b/types.c
index a4340b1..3e4d6ce 100644
--- a/types.c
+++ b/types.c
@@ -877,8 +877,14 @@ static bool call_arg_param_order(FnExpr *fn, Type *fn_type, Argument *args, Loca
nparams, plural_suffix(nparams), nargs);
return false;
}
-
- I16 *order = *orderp = err_malloc(nparams * sizeof *order);
+
+
+ I16 *order = *orderp =
+ /* thanks, gcc, for making me do this! (getting erroneous -Walloc-size-larger-than) */
+#if defined __GNUC__ && !defined __clang__
+ nparams > PTRDIFF_MAX ? NULL :
+#endif
+ err_malloc(nparams * sizeof *order);
for (size_t i = 0; i < nparams; ++i)
order[i] = -1;
@@ -1684,6 +1690,7 @@ static bool types_expr(Typer *tr, Expression *e) {
} else {
arg_exprs[i] = args[arg_idx].val;
}
+ ++i;
}
}
} else {
@@ -1729,7 +1736,7 @@ static bool types_expr(Typer *tr, Expression *e) {
Type **arg_types = NULL;
Type **decl_types = NULL;
Identifier *inferred_idents = NULL;
-
+
arr_foreach(fn->params, Declaration, param) {
arr_foreach(param->idents, Identifier, ident) {
if (param->flags & DECL_INFER) {
@@ -1744,6 +1751,7 @@ static bool types_expr(Typer *tr, Expression *e) {
*p = &param->type;
Type **q = typer_arr_add(tr, &arg_types);
*q = &arg_exprs[i].type;
+ print_expr(arg_exprs + i);
}
++i;
}