From e38ecde989fe378c49a61d6975784ccfb703cfee Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 30 Nov 2024 14:59:28 -0500 Subject: Explicitly forbid nested optional types --- typecheck.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'typecheck.c') diff --git a/typecheck.c b/typecheck.c index e602c774..82c1f84a 100644 --- a/typecheck.c +++ b/typecheck.c @@ -93,6 +93,8 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast) if (!val_type) code_err(val_type_ast, "I can't figure out what type this is."); if (has_view_memory(val_type)) code_err(val_type_ast, "Tables can't have stack references because the array may outlive the stack frame."); + else if (val_type->tag == OptionalType) + code_err(ast, "Tables with optional-typed values are not currently supported"); return Type(TableType, .key_type=key_type, .value_type=val_type); } case FunctionTypeAST: { @@ -118,6 +120,8 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast) type_t *t = parse_type_ast(env, opt->type); if (t->tag == VoidType || t->tag == AbortType || t->tag == ReturnType) code_err(ast, "Optional %T types are not supported.", t); + else if (t->tag == OptionalType) + code_err(ast, "Nested optional types are not currently supported"); return Type(OptionalType, .type=t); } case UnknownTypeAST: code_err(ast, "I don't know how to get this type"); -- cgit v1.2.3