| ... | ... | @@ -693,10 +693,11 @@ fn varDecl( |
| 693 | 693 | defer init_scope.instructions.deinit(mod.gpa); |
| 694 | 694 | |
| 695 | 695 | var resolve_inferred_alloc: ?*zir.Inst = null; |
| 696 | var opt_type_inst: ?*zir.Inst = null; |
| 696 | 697 | if (node.getTypeNode()) |type_node| { |
| 697 | 698 | const type_inst = try typeExpr(mod, &init_scope.base, type_node); |
| 698 | | const alloc = try addZIRUnOp(mod, &init_scope.base, name_src, .alloc, type_inst); |
| 699 | | init_scope.rl_ptr = alloc; |
| 699 | opt_type_inst = type_inst; |
| 700 | init_scope.rl_ptr = try addZIRUnOp(mod, &init_scope.base, name_src, .alloc, type_inst); |
| 700 | 701 | } else { |
| 701 | 702 | const alloc = try addZIRNoOpT(mod, &init_scope.base, name_src, .alloc_inferred); |
| 702 | 703 | resolve_inferred_alloc = &alloc.base; |
| ... | ... | @@ -720,12 +721,17 @@ fn varDecl( |
| 720 | 721 | parent_zir.appendAssumeCapacity(src_inst); |
| 721 | 722 | } |
| 722 | 723 | assert(parent_zir.items.len == expected_len); |
| 724 | const casted_init = if (opt_type_inst) |type_inst| |
| 725 | try addZIRBinOp(mod, scope, type_inst.src, .as, type_inst, init_inst) |
| 726 | else |
| 727 | init_inst; |
| 728 | |
| 723 | 729 | const sub_scope = try block_arena.create(Scope.LocalVal); |
| 724 | 730 | sub_scope.* = .{ |
| 725 | 731 | .parent = scope, |
| 726 | 732 | .gen_zir = scope.getGenZIR(), |
| 727 | 733 | .name = ident_name, |
| 728 | | .inst = init_inst, |
| 734 | .inst = casted_init, |
| 729 | 735 | }; |
| 730 | 736 | return &sub_scope.base; |
| 731 | 737 | } |
| ... | ... | @@ -2866,7 +2872,7 @@ fn asRlPtr( |
| 2866 | 2872 | parent_zir.appendAssumeCapacity(src_inst); |
| 2867 | 2873 | } |
| 2868 | 2874 | assert(parent_zir.items.len == expected_len); |
| 2869 | | const casted_result = try addZIRBinOp(mod, scope, result.src, .as, dest_type, result); |
| 2875 | const casted_result = try addZIRBinOp(mod, scope, dest_type.src, .as, dest_type, result); |
| 2870 | 2876 | return rvalue(mod, scope, rl, casted_result); |
| 2871 | 2877 | } else { |
| 2872 | 2878 | try parent_zir.appendSlice(mod.gpa, as_scope.instructions.items); |