| ... | @@ -2343,6 +2343,13 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa | ... | @@ -2343,6 +2343,13 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa |
| 2343 | add_node_error(g, source_node, buf_sprintf("variable of type 'type' must be constant")); | 2343 | add_node_error(g, source_node, buf_sprintf("variable of type 'type' must be constant")); |
| 2344 | implicit_type = g->builtin_types.entry_invalid; | 2344 | implicit_type = g->builtin_types.entry_invalid; |
| 2345 | } | 2345 | } |
| | 2346 | if (implicit_type->id != TypeTableEntryIdInvalid && !context->fn_entry) { |
| | 2347 | ConstExprValue *const_val = &get_resolved_expr(variable_declaration->expr)->const_val; |
| | 2348 | if (!const_val->ok) { |
| | 2349 | add_node_error(g, first_executing_node(variable_declaration->expr), |
| | 2350 | buf_sprintf("global variable initializer requires constant expression")); |
| | 2351 | } |
| | 2352 | } |
| 2346 | } | 2353 | } |
| 2347 | | 2354 | |
| 2348 | if (implicit_type == nullptr && is_const) { | 2355 | if (implicit_type == nullptr && is_const) { |