diff options
-rw-r--r-- | main.c | 5 | ||||
-rw-r--r-- | parse.c | 5 | ||||
-rw-r--r-- | test.toc | 31 |
3 files changed, 10 insertions, 31 deletions
@@ -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 @@ -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; } } @@ -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 |