diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-11 13:49:54 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-11 13:49:54 -0400 |
commit | af78ae105bbf82136c82b8727115e7ea70577e57 (patch) | |
tree | 4a4db42a7383a16c40316fbe66ee0a89eb288353 | |
parent | 8617b3bdd084cf45f4351f96e154f7ec76e0b266 (diff) |
no semiconst or struct varargs
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | parse.c | 9 | ||||
-rw-r--r-- | test.toc | 3 |
3 files changed, 12 insertions, 2 deletions
@@ -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 @@ -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; @@ -1,5 +1,8 @@ #include "std/io.toc"; +s ::= struct(x::..) { +}; + f ::= fn(x : ..) int { total := 0; for _, i := x { |