diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-19 11:18:43 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-02-19 11:18:43 -0500 |
commit | 98585d13741499bb370e9c9bedd0d2c390905f21 (patch) | |
tree | dbd70299713bcf00e8973c8f47883c44786e2c08 | |
parent | 9bb0fab71acd8c730fff396bd93154f916ba397b (diff) |
struct parameters mostly working, but for some reason it doesnt want to leave the struct scope
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | parse.c | 11 | ||||
-rw-r--r-- | test.toc | 4 |
3 files changed, 15 insertions, 4 deletions
@@ -19,9 +19,9 @@ /* TODO: struct parameters -- error on empty parameter list - error on non-const param decls -- make sure inference works +- allow accessing parameters with . +- get rid of inference - should argument set twice error be in call_arg_param_order? --- see infer.c "is resolved_to necessary" (now that ident system has changed) @@ -609,8 +609,19 @@ static bool parse_type(Parser *p, Type *type) { ++t->token; if (token_is_kw(t->token, KW_LPAREN)) { ++t->token; + if (token_is_kw(t->token, KW_RPAREN)) { + tokr_err(t, "Empty struct parameter lists are not allowed."); + goto struct_fail; + } if (!parse_decl_list(p, &struc->params, DECL_END_RPAREN_COMMA)) goto struct_fail; + + arr_foreach(struc->params, Declaration, param) { + if (!(param->flags & DECL_IS_CONST)) { + err_print(param->where, "Struct parameters must be constant."); + goto struct_fail; + } + } } if (!token_is_kw(t->token, KW_LBRACE)) { tokr_err(t, "Expected { to follow struct."); @@ -2,8 +2,8 @@ io ::= nms { #include "std/io.toc"; }; -Arr ::= struct(t::Type) { - data: []t; +Arr ::= struct(x::Type) { + data: []x; }; main ::= fn() { |