From d127c1d59ebf19e5ffaedece99a39f69712683b0 Mon Sep 17 00:00:00 2001 From: Daniele Cocca Date: Sat, 30 Apr 2022 07:34:21 +0100 Subject: 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. --- src/codegen/c.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 8f73daca46..2cd93d47fc 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -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}"); -- cgit v1.2.3