diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-15 12:02:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-15 12:02:55 -0400 |
| commit | 4c83b11f71564e0de80f496f471ca6dfb83a95e3 (patch) | |
| tree | 74169b63dd4334421f353e947ad90dddff672ac7 /test/behavior/basic.zig | |
| parent | 02a43f325bfbccb73fb773f15b162d531c3c3ada (diff) | |
| parent | dbe0d3d5790d9e21cf42696d4cea8cc477207592 (diff) | |
| download | zig-4c83b11f71564e0de80f496f471ca6dfb83a95e3.tar.gz zig-4c83b11f71564e0de80f496f471ca6dfb83a95e3.zip | |
Merge pull request #11438 from Vexu/stage2-fixes
Stage2 fixes
Diffstat (limited to 'test/behavior/basic.zig')
| -rw-r--r-- | test/behavior/basic.zig | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index 134ca1a235..96aa6900ee 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -859,7 +859,6 @@ test "catch in block has correct result location" { if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const S = struct { fn open() error{A}!@This() { @@ -887,3 +886,22 @@ test "labeled block with runtime branch forwards its result location type to bre }; try expect(e == .b); } + +test "try in labeled block doesn't cast to wrong type" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + + const S = struct { + a: u32, + fn foo() anyerror!u32 { + return 1; + } + }; + const s: ?*S = blk: { + var a = try S.foo(); + + _ = a; + break :blk null; + }; + _ = s; +} |
