summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-11 13:49:54 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-11 13:49:54 -0400
commitaf78ae105bbf82136c82b8727115e7ea70577e57 (patch)
tree4a4db42a7383a16c40316fbe66ee0a89eb288353
parent8617b3bdd084cf45f4351f96e154f7ec76e0b266 (diff)
no semiconst or struct varargs
-rw-r--r--main.c2
-rw-r--r--parse.c9
-rw-r--r--test.toc3
3 files changed, 12 insertions, 2 deletions
diff --git a/main.c b/main.c
index d6ea395..f08d5d9 100644
--- a/main.c
+++ b/main.c
@@ -8,8 +8,6 @@
/*
TODO:
-don't allow semiconst varargs
-don't allow struct varargs (yet)
make sure varargs[i] isn't an lvalue
make sure you can't have a variadic function pointer
make sure varargs works with inference
diff --git a/parse.c b/parse.c
index d5b21a4..1430d2e 100644
--- a/parse.c
+++ b/parse.c
@@ -649,6 +649,11 @@ static Status parse_type(Parser *p, Type *type, Location *where) {
err_print(param->where, "Struct parameters must be constant.");
goto struct_fail;
}
+ if ((param->flags & DECL_ANNOTATES_TYPE) && type_is_builtin(&param->type, BUILTIN_VARARGS)) {
+ /* TODO(eventually) */
+ err_print(param->where, "structs cannot have varargs parameters (yet).");
+ goto struct_fail;
+ }
if (param->flags & DECL_INFER) {
/* TODO(eventually) */
err_print(param->where, "Struct parameters cannot be inferred (yet).");
@@ -2286,6 +2291,10 @@ static Status parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, U16 f
d->type.was_expr = NULL;
d->type.builtin = BUILTIN_VARARGS;
is_varargs = true;
+ if (d->flags & DECL_SEMI_CONST) {
+ tokr_err(t, "Semi-constant varargs are not allowed. Sorry!");
+ goto ret_false;
+ }
++t->token;
} else {
Type type;
diff --git a/test.toc b/test.toc
index da2dd79..53efe0d 100644
--- a/test.toc
+++ b/test.toc
@@ -1,5 +1,8 @@
#include "std/io.toc";
+s ::= struct(x::..) {
+};
+
f ::= fn(x : ..) int {
total := 0;
for _, i := x {