summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c4
-rw-r--r--parse.c11
-rw-r--r--test.toc4
3 files changed, 15 insertions, 4 deletions
diff --git a/main.c b/main.c
index f8d4b69..103457b 100644
--- a/main.c
+++ b/main.c
@@ -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)
diff --git a/parse.c b/parse.c
index 8bd56fb..17c9819 100644
--- a/parse.c
+++ b/parse.c
@@ -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.");
diff --git a/test.toc b/test.toc
index 3dabdc3..4ab4dc8 100644
--- a/test.toc
+++ b/test.toc
@@ -2,8 +2,8 @@ io ::= nms {
#include "std/io.toc";
};
-Arr ::= struct(t::Type) {
- data: []t;
+Arr ::= struct(x::Type) {
+ data: []x;
};
main ::= fn() {