ir: Disallow comparison between enum literal and untagged enum
Closes #4770
This commit is contained in:
@@ -14,6 +14,17 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:2:15: error: unused variable: 'a'",
|
||||
});
|
||||
|
||||
cases.addTest("comparison of non-tagged union and enum literal",
|
||||
\\export fn entry() void {
|
||||
\\ const U = union { A: u32, B: u64 };
|
||||
\\ var u = U{ .A = 42 };
|
||||
\\ var ok = u == .A;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:4:16: error: comparison of union and enum literal is only valid for tagged union types",
|
||||
"tmp.zig:2:15: note: type U is not a tagged union",
|
||||
});
|
||||
|
||||
cases.addTest("shift on type with non-power-of-two size",
|
||||
\\export fn entry() void {
|
||||
\\ const S = struct {
|
||||
|
||||
Reference in New Issue
Block a user