| author | |
| committer | |
| log | 3e74acb1390e7b18a1d0febf9540585e165b52bd |
| tree | a3659a55985453be2c29708be2de0b22dda245af |
| parent | 13321c8070b52afb24f3c1b57eecbb2aa77fc4ec |
They aren't inline blocks by nature of being labeled.
Fixes #112133 files changed, 39 insertions(+), 1 deletions(-)
src/AstGen.zig+1-1| ... | ... | @@ -2018,7 +2018,7 @@ fn labeledBlockExpr( |
| 2018 | 2018 | |
| 2019 | 2019 | try blockExprStmts(&block_scope, &block_scope.base, statements); |
| 2020 | 2020 | if (!block_scope.endsWithNoReturn()) { |
| 2021 | _ = try block_scope.addBreak(.break_inline, block_inst, .void_value); | |
| 2021 | _ = try block_scope.addBreak(.@"break", block_inst, .void_value); | |
| 2022 | 2022 | } |
| 2023 | 2023 | |
| 2024 | 2024 | if (!block_scope.label.?.used) { |
test/behavior.zig+1| ... | ... | @@ -70,6 +70,7 @@ test { |
| 70 | 70 | _ = @import("behavior/bugs/11165.zig"); |
| 71 | 71 | _ = @import("behavior/bugs/11181.zig"); |
| 72 | 72 | _ = @import("behavior/bugs/11182.zig"); |
| 73 | _ = @import("behavior/bugs/11213.zig"); | |
| 73 | 74 | _ = @import("behavior/call.zig"); |
| 74 | 75 | _ = @import("behavior/cast.zig"); |
| 75 | 76 | _ = @import("behavior/comptime_memory.zig"); |
test/behavior/bugs/11213.zig created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const testing = std.testing; | |
| 4 | ||
| 5 | test { | |
| 6 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | |
| 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 8 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | |
| 9 | ||
| 10 | const g: error{Test}!void = error.Test; | |
| 11 | ||
| 12 | var v: u32 = 0; | |
| 13 | hash(&v, g); | |
| 14 | try testing.expect(v == 1); | |
| 15 | } | |
| 16 | ||
| 17 | fn hash(v: *u32, key: anytype) void { | |
| 18 | const Key = @TypeOf(key); | |
| 19 | ||
| 20 | if (@typeInfo(Key) == .ErrorSet) { | |
| 21 | v.* += 1; | |
| 22 | return; | |
| 23 | } | |
| 24 | ||
| 25 | switch (@typeInfo(Key)) { | |
| 26 | .ErrorUnion => blk: { | |
| 27 | const payload = key catch |err| { | |
| 28 | hash(v, err); | |
| 29 | break :blk; | |
| 30 | }; | |
| 31 | ||
| 32 | hash(v, payload); | |
| 33 | }, | |
| 34 | ||
| 35 | else => unreachable, | |
| 36 | } | |
| 37 | } |