| author | |
| committer | |
| log | d127c1d59ebf19e5ffaedece99a39f69712683b0 |
| tree | a0eeee42fefce1fba094ab8ce6851452aba561ac |
| parent | 032c722d2019a475362c0ae01241a80417bdd8a2 |
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.2 files changed, 1 insertions(+), 3 deletions(-)
src/codegen/c.zig+1-1| ... | ... | @@ -580,7 +580,7 @@ pub const DeclGen = struct { |
| 580 | 580 | 64 => return writer.writeAll("(void *)0xaaaaaaaaaaaaaaaa"), |
| 581 | 581 | else => unreachable, |
| 582 | 582 | }, |
| 583 | .Struct => { | |
| 583 | .Struct, .ErrorUnion => { | |
| 584 | 584 | try writer.writeByte('('); |
| 585 | 585 | try dg.renderTypecast(writer, ty); |
| 586 | 586 | return writer.writeAll("){0xaa}"); |
test/behavior/sizeof_and_typeof.zig-2| ... | ... | @@ -187,7 +187,6 @@ test "@sizeOf(T) == 0 doesn't force resolving struct size" { |
| 187 | 187 | |
| 188 | 188 | test "@TypeOf() has no runtime side effects" { |
| 189 | 189 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 190 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 191 | 190 | const S = struct { |
| 192 | 191 | fn foo(comptime T: type, ptr: *T) T { |
| 193 | 192 | ptr.* += 1; |
| ... | ... | @@ -203,7 +202,6 @@ test "@TypeOf() has no runtime side effects" { |
| 203 | 202 | test "branching logic inside @TypeOf" { |
| 204 | 203 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 205 | 204 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 206 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 207 | 205 | const S = struct { |
| 208 | 206 | var data: i32 = 0; |
| 209 | 207 | fn foo() anyerror!i32 { |