diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-30 14:59:28 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-30 14:59:28 -0500 |
| commit | e38ecde989fe378c49a61d6975784ccfb703cfee (patch) | |
| tree | de045602fdc032854a7c2838706d1aaaccdc9746 /typecheck.c | |
| parent | 18c1ce7fd18c02abda235781db780c9d5fe73ad4 (diff) | |
Explicitly forbid nested optional types
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 4 |
1 files changed, 4 insertions, 0 deletions
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"); |
