summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c5
-rw-r--r--parse.c5
-rw-r--r--test.toc31
3 files changed, 10 insertions, 31 deletions
diff --git a/main.c b/main.c
index e0c3a11..d83c2e7 100644
--- a/main.c
+++ b/main.c
@@ -18,13 +18,8 @@
/*
TODO:
-- split up a,b::int for parameterized structs (?also maybe normal const parameters?)
- allow accessing parameters with .
- make call_arg_param_order work more like parameterized_struct_arg_order
-
-- error on inferred struct param
-does this work: fn (a::=3, b::=2)
- - should either work or give an error: fn()
---
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
diff --git a/parse.c b/parse.c
index a0ed884..254d687 100644
--- a/parse.c
+++ b/parse.c
@@ -621,6 +621,11 @@ static bool parse_type(Parser *p, Type *type) {
err_print(param->where, "Struct parameters must be constant.");
goto struct_fail;
}
+ if (param->flags & DECL_INFER) {
+ /* TODO(eventually) */
+ err_print(param->where, "Struct parameters cannot be inferred (yet).");
+ goto struct_fail;
+ }
param->flags |= DECL_IS_PARAM;
}
}
diff --git a/test.toc b/test.toc
index c9ef4b3..5eef11f 100644
--- a/test.toc
+++ b/test.toc
@@ -2,33 +2,12 @@ io ::= nms {
#include "std/io.toc";
};
-
-
-Thing ::= struct(t::=int, u::t=3) {
- it : t;
- that : [u]t;
-};
-
-f ::= fn(t,u::=,th : &Thing(t,u)) {
- x: t = 17 as t;
- th.it = x;
- for p, i := &th.that {
- *p = i as t;
- }
-};
-
-print_thing ::= fn(t, u::=, th: Thing(t, u)) {
- io.puti(th.it as int);
- for x := th.that {
- io.puti(x as int);
- }
+f ::= fn(a,b::=3) int {
+ a + b
};
main ::= fn() {
- a: Thing(u = 5, t = u8);
- f(&a);
- print_thing(a);
- b: Thing();
- f(&b);
- print_thing(b);
+ x ::= f();
+ io.puti(x);
+ io.puti(f());
}; \ No newline at end of file