mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
stage2: fix airIsErr when is_ptr == true
This commit is contained in:
parent
1f748fe426
commit
03b1fbe50d
@ -3618,8 +3618,9 @@ fn airIsErr(
|
||||
const operand = try f.resolveInst(un_op);
|
||||
const operand_ty = f.air.typeOf(un_op);
|
||||
const local = try f.allocLocal(Type.initTag(.bool), .Const);
|
||||
const payload_ty = operand_ty.errorUnionPayload();
|
||||
const error_ty = operand_ty.errorUnionSet();
|
||||
const err_union_ty = if (is_ptr) operand_ty.childType() else operand_ty;
|
||||
const payload_ty = err_union_ty.errorUnionPayload();
|
||||
const error_ty = err_union_ty.errorUnionSet();
|
||||
|
||||
try writer.writeAll(" = ");
|
||||
|
||||
|
||||
@ -5693,7 +5693,8 @@ pub const FuncGen = struct {
|
||||
|
||||
const un_op = self.air.instructions.items(.data)[inst].un_op;
|
||||
const operand = try self.resolveInst(un_op);
|
||||
const err_union_ty = self.air.typeOf(un_op);
|
||||
const operand_ty = self.air.typeOf(un_op);
|
||||
const err_union_ty = if (operand_is_ptr) operand_ty.childType() else operand_ty;
|
||||
const payload_ty = err_union_ty.errorUnionPayload();
|
||||
const err_set_ty = try self.dg.lowerType(Type.initTag(.anyerror));
|
||||
const zero = err_set_ty.constNull();
|
||||
|
||||
@ -724,3 +724,15 @@ test "simple else prong allowed even when all errors handled" {
|
||||
};
|
||||
try expect(value == 255);
|
||||
}
|
||||
|
||||
test {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
var err_union: anyerror!u8 = 15;
|
||||
|
||||
const payload_ptr = &(err_union catch unreachable);
|
||||
try expect(payload_ptr.* == 15);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user