mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 15:12:31 +00:00
AstGen: add missing rvalue
call to labeledBlockExpr
...and fix a minor x86_64 backend bug exposed by this fix. Resolves: #21974
This commit is contained in:
parent
9fa9c7abd0
commit
bbbc95afd0
@ -2435,6 +2435,7 @@ fn blockExpr(
|
||||
if (!block_scope.endsWithNoReturn()) {
|
||||
// As our last action before the break, "pop" the error trace if needed
|
||||
_ = try gz.addRestoreErrRetIndex(.{ .block = block_inst }, .always, block_node);
|
||||
// No `rvalue` call here, as the block result is always `void`, so we do that below.
|
||||
_ = try block_scope.addBreak(.@"break", block_inst, .void_value);
|
||||
}
|
||||
|
||||
@ -2531,7 +2532,8 @@ fn labeledBlockExpr(
|
||||
if (!block_scope.endsWithNoReturn()) {
|
||||
// As our last action before the return, "pop" the error trace if needed
|
||||
_ = try gz.addRestoreErrRetIndex(.{ .block = block_inst }, .always, block_node);
|
||||
_ = try block_scope.addBreak(.@"break", block_inst, .void_value);
|
||||
const result = try rvalue(gz, block_scope.break_result_info, .void_value, block_node);
|
||||
_ = try block_scope.addBreak(.@"break", block_inst, result);
|
||||
}
|
||||
|
||||
if (!block_scope.label.?.used) {
|
||||
|
@ -532,6 +532,8 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
},
|
||||
else => unreachable,
|
||||
};
|
||||
} else {
|
||||
return lower.fail("TODO: bin format '{s}'", .{@tagName(lower.bin_file.tag)});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
10
test/cases/compile_errors/labeled_block_implicit_value.zig
Normal file
10
test/cases/compile_errors/labeled_block_implicit_value.zig
Normal file
@ -0,0 +1,10 @@
|
||||
export fn foo() void {
|
||||
const result: u32 = b: {
|
||||
if (false) break :b 1;
|
||||
};
|
||||
_ = result;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:28: error: expected type 'u32', found 'void'
|
Loading…
Reference in New Issue
Block a user