| author | |
| committer | |
| log | c9e01412a451419491786bf3db1713875928092c |
| tree | afb3832a64f5b8e942c24b076cc64dd39c5af406 |
| parent | f55fdc00fcde3cd17ed0ddb94c0997c882dbe6b9 |
...a switch prong of a switch with 2 prongs in an else
closes #6563 files changed, 34 insertions(+), 3 deletions(-)
src/ir.cpp+3-3| ... | ... | @@ -1191,6 +1191,8 @@ static IrInstruction *ir_build_var_decl(IrBuilder *irb, Scope *scope, AstNode *s |
| 1191 | 1191 | if (align_value) ir_ref_instruction(align_value, irb->current_basic_block); |
| 1192 | 1192 | ir_ref_instruction(init_value, irb->current_basic_block); |
| 1193 | 1193 | |
| 1194 | var->decl_instruction = &decl_var_instruction->base; | |
| 1195 | ||
| 1194 | 1196 | return &decl_var_instruction->base; |
| 1195 | 1197 | } |
| 1196 | 1198 | |
| ... | ... | @@ -5108,9 +5110,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 5108 | 5110 | if (init_value == irb->codegen->invalid_instruction) |
| 5109 | 5111 | return init_value; |
| 5110 | 5112 | |
| 5111 | IrInstruction *result = ir_build_var_decl(irb, scope, node, var, type_instruction, align_value, init_value); | |
| 5112 | var->decl_instruction = result; | |
| 5113 | return result; | |
| 5113 | return ir_build_var_decl(irb, scope, node, var, type_instruction, align_value, init_value); | |
| 5114 | 5114 | } |
| 5115 | 5115 | |
| 5116 | 5116 | static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *node) { |
test/behavior.zig+1| ... | ... | @@ -8,6 +8,7 @@ comptime { |
| 8 | 8 | _ = @import("cases/bool.zig"); |
| 9 | 9 | _ = @import("cases/bugs/394.zig"); |
| 10 | 10 | _ = @import("cases/bugs/655.zig"); |
| 11 | _ = @import("cases/bugs/656.zig"); | |
| 11 | 12 | _ = @import("cases/cast.zig"); |
| 12 | 13 | _ = @import("cases/const_slice_child.zig"); |
| 13 | 14 | _ = @import("cases/defer.zig"); |
test/cases/bugs/656.zig created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | const assert = @import("std").debug.assert; | |
| 2 | ||
| 3 | const PrefixOp = union(enum) { | |
| 4 | Return, | |
| 5 | AddrOf: Value, | |
| 6 | }; | |
| 7 | ||
| 8 | const Value = struct { | |
| 9 | align_expr: ?u32, | |
| 10 | }; | |
| 11 | ||
| 12 | test "nullable if after an if in a switch prong of a switch with 2 prongs in an else" { | |
| 13 | foo(false, true); | |
| 14 | } | |
| 15 | ||
| 16 | fn foo(a: bool, b: bool) { | |
| 17 | var prefix_op = PrefixOp { .AddrOf = Value { .align_expr = 1234 } }; | |
| 18 | if (a) { | |
| 19 | } else { | |
| 20 | switch (prefix_op) { | |
| 21 | PrefixOp.AddrOf => |addr_of_info| { | |
| 22 | if (b) { } | |
| 23 | if (addr_of_info.align_expr) |align_expr| { | |
| 24 | assert(align_expr == 1234); | |
| 25 | } | |
| 26 | }, | |
| 27 | PrefixOp.Return => {}, | |
| 28 | } | |
| 29 | } | |
| 30 | } |