From af78ae105bbf82136c82b8727115e7ea70577e57 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 11 Mar 2020 13:49:54 -0400 Subject: no semiconst or struct varargs --- main.c | 2 -- parse.c | 9 +++++++++ test.toc | 3 +++ 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(¶m->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 { -- cgit v1.2.3