| ... | ... | @@ -2178,6 +2178,23 @@ test "matching captures causes union equivalence" { |
| 2178 | 2178 | try expect(a.u == b.u); |
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | test "capture used as explicit field value" { |
| 2182 | const S = struct { |
| 2183 | fn Union(n: u8) type { |
| 2184 | return union(enum(u8)) { |
| 2185 | a: u32 = n, |
| 2186 | b, |
| 2187 | }; |
| 2188 | } |
| 2189 | }; |
| 2190 | |
| 2191 | comptime assert(@typeInfo(S.Union(0)).@"union".tag_type.? != @typeInfo(S.Union(1)).@"union".tag_type.?); |
| 2192 | |
| 2193 | const s: S.Union(1) = .{ .a = 0 }; |
| 2194 | try expect(@backingInt(s) == 1); |
| 2195 | try expect(@backingInt(@as(@typeInfo(S.Union(1)).@"union".tag_type.?, s)) == 1); |
| 2196 | } |
| 2197 | |
| 2181 | 2198 | test "signed enum tag with negative value" { |
| 2182 | 2199 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 2183 | 2200 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |