| ... | @@ -5771,8 +5771,8 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -5771,8 +5771,8 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 5771 | bool is_const = variable_declaration->is_const; | 5771 | bool is_const = variable_declaration->is_const; |
| 5772 | bool is_extern = variable_declaration->is_extern; | 5772 | bool is_extern = variable_declaration->is_extern; |
| 5773 | | 5773 | |
| 5774 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, | 5774 | bool is_comptime_scalar = ir_should_inline(irb->exec, scope) || variable_declaration->is_comptime; |
| 5775 | ir_should_inline(irb->exec, scope) || variable_declaration->is_comptime); | 5775 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, is_comptime_scalar); |
| 5776 | ZigVar *var = ir_create_var(irb, node, scope, variable_declaration->symbol, | 5776 | ZigVar *var = ir_create_var(irb, node, scope, variable_declaration->symbol, |
| 5777 | is_const, is_const, is_shadowable, is_comptime); | 5777 | is_const, is_const, is_shadowable, is_comptime); |
| 5778 | // we detect IrInstructionIdDeclVarSrc in gen_block to make sure the next node | 5778 | // we detect IrInstructionIdDeclVarSrc in gen_block to make sure the next node |
| ... | @@ -5806,11 +5806,15 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -5806,11 +5806,15 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 5806 | ResultLocVar *result_loc_var = create_var_result_loc(alloca, var); | 5806 | ResultLocVar *result_loc_var = create_var_result_loc(alloca, var); |
| 5807 | ResultLoc *init_result_loc = (type_instruction == nullptr) ? &result_loc_var->base : nullptr; | 5807 | ResultLoc *init_result_loc = (type_instruction == nullptr) ? &result_loc_var->base : nullptr; |
| 5808 | | 5808 | |
| | 5809 | Scope *init_scope = is_comptime_scalar ? |
| | 5810 | create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope; |
| | 5811 | |
| 5809 | // Temporarily set the name of the IrExecutable to the VariableDeclaration | 5812 | // Temporarily set the name of the IrExecutable to the VariableDeclaration |
| 5810 | // so that the struct or enum from the init expression inherits the name. | 5813 | // so that the struct or enum from the init expression inherits the name. |
| 5811 | Buf *old_exec_name = irb->exec->name; | 5814 | Buf *old_exec_name = irb->exec->name; |
| 5812 | irb->exec->name = variable_declaration->symbol; | 5815 | irb->exec->name = variable_declaration->symbol; |
| 5813 | IrInstruction *init_value = ir_gen_node_extra(irb, variable_declaration->expr, scope, LValNone, init_result_loc); | 5816 | IrInstruction *init_value = ir_gen_node_extra(irb, variable_declaration->expr, init_scope, |
| | 5817 | LValNone, init_result_loc); |
| 5814 | irb->exec->name = old_exec_name; | 5818 | irb->exec->name = old_exec_name; |
| 5815 | | 5819 | |
| 5816 | if (init_value == irb->codegen->invalid_instruction) | 5820 | if (init_value == irb->codegen->invalid_instruction) |
| ... | @@ -8029,7 +8033,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -8029,7 +8033,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 8029 | case NodeTypeContainerInitExpr: | 8033 | case NodeTypeContainerInitExpr: |
| 8030 | return ir_gen_container_init_expr(irb, scope, node, lval, result_loc); | 8034 | return ir_gen_container_init_expr(irb, scope, node, lval, result_loc); |
| 8031 | case NodeTypeVariableDeclaration: | 8035 | case NodeTypeVariableDeclaration: |
| 8032 | return ir_lval_wrap(irb, scope, ir_gen_var_decl(irb, scope, node), lval, result_loc); | 8036 | return ir_gen_var_decl(irb, scope, node); |
| 8033 | case NodeTypeWhileExpr: | 8037 | case NodeTypeWhileExpr: |
| 8034 | return ir_gen_while_expr(irb, scope, node, lval, result_loc); | 8038 | return ir_gen_while_expr(irb, scope, node, lval, result_loc); |
| 8035 | case NodeTypeForExpr: | 8039 | case NodeTypeForExpr: |