aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkkHAIKE <kkhaike@gmail.com>2022-09-17 20:16:40 +0800
committerVeikka Tuominen <git@vexu.eu>2022-09-21 20:21:02 +0300
commit4961044ce8d06f43bf6f43c103433d70a1fbd79a (patch)
tree8a80cdc1f4bd24380b511aaf425da697ca910933 /src
parent183127733c8ab51c05f4d4b5cee2a1497272172a (diff)
downloadzig-4961044ce8d06f43bf6f43c103433d70a1fbd79a.tar.gz
zig-4961044ce8d06f43bf6f43c103433d70a1fbd79a.zip
AstGen: store void to ptr result loc when there is no else branch
Diffstat (limited to 'src')
-rw-r--r--src/AstGen.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index 8d91edd7b2..7d567b223d 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -5570,7 +5570,11 @@ fn ifExpr(
};
} else .{
.src = if_full.ast.then_expr,
- .result = .none,
+ .result = switch (rl) {
+ // Explicitly store void to ptr result loc if there is no else branch
+ .ptr, .block_ptr => try rvalue(&else_scope, rl, .void_value, node),
+ else => .none,
+ },
};
const break_tag: Zir.Inst.Tag = if (parent_gz.force_comptime) .break_inline else .@"break";