aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-02-01 21:41:02 +0200
committerVeikka Tuominen <git@vexu.eu>2023-02-02 00:31:35 +0200
commit629c3108aa71f94bd26dba8d4f20c9f3a3945bd4 (patch)
tree3e324f6279c895f5e09255013926c8eb7060a334 /src
parent490addde278001694d554a9a9fe2eb8235831143 (diff)
downloadzig-629c3108aa71f94bd26dba8d4f20c9f3a3945bd4.tar.gz
zig-629c3108aa71f94bd26dba8d4f20c9f3a3945bd4.zip
AstGen: fix orelse type coercion in call arguments
Closes #14506
Diffstat (limited to 'src')
-rw-r--r--src/AstGen.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig
index a5667ce9e8..10673a2b37 100644
--- a/src/AstGen.zig
+++ b/src/AstGen.zig
@@ -8721,6 +8721,7 @@ fn callExpr(
defer arg_block.unstack();
// `call_inst` is reused to provide the param type.
+ arg_block.rl_ty_inst = call_inst;
const arg_ref = try expr(&arg_block, &arg_block.base, .{ .rl = .{ .coerced_ty = call_inst }, .ctx = .fn_arg }, param_node);
_ = try arg_block.addBreak(.break_inline, call_index, arg_ref);
@@ -10869,7 +10870,12 @@ const GenZir = struct {
// we emit ZIR for the block break instructions to have the result values,
// and then rvalue() on that to pass the value to the result location.
switch (parent_ri.rl) {
- .ty, .coerced_ty => |ty_inst| {
+ .coerced_ty => |ty_inst| {
+ // Type coercion needs to happend before breaks.
+ gz.rl_ty_inst = ty_inst;
+ gz.break_result_info = .{ .rl = .{ .ty = ty_inst } };
+ },
+ .ty => |ty_inst| {
gz.rl_ty_inst = ty_inst;
gz.break_result_info = parent_ri;
},