aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-04-15 10:41:35 +0300
committerVeikka Tuominen <git@vexu.eu>2022-04-15 11:17:06 +0300
commit4911d39769e3b9ccf07062751106aa388bc97e48 (patch)
tree0594deb662f41f4fb404a937e7e6d4902c118081 /test/behavior/basic.zig
parent4ef1c1c705ceb2d89d0bf93d7a2403c165ae9dc0 (diff)
downloadzig-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.zig20
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;
+}