File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -7261,6 +7261,8 @@ fn zirOptionalPayload(
7261
7261
if (operand_ty.ptrSize() != .C) {
7262
7262
return sema.failWithExpectedOptionalType(block, src, operand_ty);
7263
7263
}
7264
+ // TODO https://github.com/ziglang/zig/issues/6597
7265
+ if (true) break :t operand_ty;
7264
7266
const ptr_info = operand_ty.ptrInfo().data;
7265
7267
break :t try Type.ptr(sema.arena, sema.mod, .{
7266
7268
.pointee_type = try ptr_info.pointee_type.copy(sema.arena),
Original file line number Diff line number Diff line change @@ -405,3 +405,10 @@ test "optional of noreturn used with orelse" {
405
405
const val = NoReturn .testOrelse ();
406
406
try expect (val == 123 );
407
407
}
408
+
409
+ test "orelse on C pointer" {
410
+ // TODO https://github.com/ziglang/zig/issues/6597
411
+ const foo : [* c ]const u8 = "hey" ;
412
+ const d = foo orelse @compileError ("bad" );
413
+ try expectEqual ([* c ]const u8 , @TypeOf (d ));
414
+ }
You can’t perform that action at this time.
0 commit comments