| ... | @@ -421,9 +421,17 @@ static TypeTableEntry * analyze_expression(CodeGen *g, ImportTableEntry *import, | ... | @@ -421,9 +421,17 @@ static TypeTableEntry * analyze_expression(CodeGen *g, ImportTableEntry *import, |
| 421 | | 421 | |
| 422 | TypeTableEntry *explicit_type = variable_declaration->type != nullptr ? | 422 | TypeTableEntry *explicit_type = variable_declaration->type != nullptr ? |
| 423 | resolve_type(g, variable_declaration->type) : nullptr; | 423 | resolve_type(g, variable_declaration->type) : nullptr; |
| | 424 | if (explicit_type == g->builtin_types.entry_unreachable) { |
| | 425 | add_node_error(g, variable_declaration->type, |
| | 426 | buf_sprintf("variable of type 'unreachable' is not allowed.")); |
| | 427 | } |
| 424 | | 428 | |
| 425 | TypeTableEntry *implicit_type = variable_declaration->expr != nullptr ? | 429 | TypeTableEntry *implicit_type = variable_declaration->expr != nullptr ? |
| 426 | analyze_expression(g, import, context, explicit_type, variable_declaration->expr) : nullptr; | 430 | analyze_expression(g, import, context, explicit_type, variable_declaration->expr) : nullptr; |
| | 431 | if (implicit_type == g->builtin_types.entry_unreachable) { |
| | 432 | add_node_error(g, node, |
| | 433 | buf_sprintf("variable initialization is unreachable.")); |
| | 434 | } |
| 427 | | 435 | |
| 428 | if (implicit_type == nullptr) { | 436 | if (implicit_type == nullptr) { |
| 429 | add_node_error(g, node, buf_sprintf("initial values are required for variable declaration.")); | 437 | add_node_error(g, node, buf_sprintf("initial values are required for variable declaration.")); |
| ... | @@ -715,6 +723,11 @@ static void analyze_top_level_declaration(CodeGen *g, ImportTableEntry *import, | ... | @@ -715,6 +723,11 @@ static void analyze_top_level_declaration(CodeGen *g, ImportTableEntry *import, |
| 715 | assert(param_decl->type->type == NodeTypeType); | 723 | assert(param_decl->type->type == NodeTypeType); |
| 716 | TypeTableEntry *type = param_decl->type->codegen_node->data.type_node.entry; | 724 | TypeTableEntry *type = param_decl->type->codegen_node->data.type_node.entry; |
| 717 | | 725 | |
| | 726 | if (type == g->builtin_types.entry_unreachable) { |
| | 727 | add_node_error(g, param_decl->type, |
| | 728 | buf_sprintf("parameter of type 'unreachable' is not allowed.")); |
| | 729 | } |
| | 730 | |
| 718 | LocalVariableTableEntry *variable_entry = allocate<LocalVariableTableEntry>(1); | 731 | LocalVariableTableEntry *variable_entry = allocate<LocalVariableTableEntry>(1); |
| 719 | buf_init_from_buf(&variable_entry->name, &param_decl->name); | 732 | buf_init_from_buf(&variable_entry->name, &param_decl->name); |
| 720 | variable_entry->type = type; | 733 | variable_entry->type = type; |