mirror of
https://github.com/ziglang/zig.git
synced 2025-12-13 17:53:07 +00:00
CBE: handle returning undefined for ErrorUnion
Just like for Struct in 8238d4b33585a715c58ab559cd001dd3ea1db55b, in the
case of ErrorUnion struct we need to return a compound literal "(T){...}"
instead of just "{}", which is invalid code when used in e.g. a "return"
expression.
This commit is contained in:
parent
032c722d20
commit
d127c1d59e
@ -580,7 +580,7 @@ pub const DeclGen = struct {
|
||||
64 => return writer.writeAll("(void *)0xaaaaaaaaaaaaaaaa"),
|
||||
else => unreachable,
|
||||
},
|
||||
.Struct => {
|
||||
.Struct, .ErrorUnion => {
|
||||
try writer.writeByte('(');
|
||||
try dg.renderTypecast(writer, ty);
|
||||
return writer.writeAll("){0xaa}");
|
||||
|
||||
@ -187,7 +187,6 @@ test "@sizeOf(T) == 0 doesn't force resolving struct size" {
|
||||
|
||||
test "@TypeOf() has no runtime side effects" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
const S = struct {
|
||||
fn foo(comptime T: type, ptr: *T) T {
|
||||
ptr.* += 1;
|
||||
@ -203,7 +202,6 @@ test "@TypeOf() has no runtime side effects" {
|
||||
test "branching logic inside @TypeOf" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
const S = struct {
|
||||
var data: i32 = 0;
|
||||
fn foo() anyerror!i32 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user