mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Sema: make orelse with C pointers behave like stage1 for now
Closes #12537
This commit is contained in:
parent
c1afe57d70
commit
74c7782c60
@ -7261,6 +7261,8 @@ fn zirOptionalPayload(
|
||||
if (operand_ty.ptrSize() != .C) {
|
||||
return sema.failWithExpectedOptionalType(block, src, operand_ty);
|
||||
}
|
||||
// TODO https://github.com/ziglang/zig/issues/6597
|
||||
if (true) break :t operand_ty;
|
||||
const ptr_info = operand_ty.ptrInfo().data;
|
||||
break :t try Type.ptr(sema.arena, sema.mod, .{
|
||||
.pointee_type = try ptr_info.pointee_type.copy(sema.arena),
|
||||
|
||||
@ -405,3 +405,10 @@ test "optional of noreturn used with orelse" {
|
||||
const val = NoReturn.testOrelse();
|
||||
try expect(val == 123);
|
||||
}
|
||||
|
||||
test "orelse on C pointer" {
|
||||
// TODO https://github.com/ziglang/zig/issues/6597
|
||||
const foo: [*c]const u8 = "hey";
|
||||
const d = foo orelse @compileError("bad");
|
||||
try expectEqual([*c]const u8, @TypeOf(d));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user