diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-04-15 10:41:35 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-04-15 11:17:06 +0300 |
| commit | 4911d39769e3b9ccf07062751106aa388bc97e48 (patch) | |
| tree | 0594deb662f41f4fb404a937e7e6d4902c118081 /test/behavior/basic.zig | |
| parent | 4ef1c1c705ceb2d89d0bf93d7a2403c165ae9dc0 (diff) | |
| download | zig-4911d39769e3b9ccf07062751106aa388bc97e48.tar.gz zig-4911d39769e3b9ccf07062751106aa388bc97e48.zip | |
AstGen: handle rl_ty_inst for mutable variables
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; +} |
