Merge pull request #13744 from Vexu/stage2-fixes
Improve error messages, fix dependency loops
This commit is contained in:
29
test/cases/compile_errors/invalid_compare_string.zig
Normal file
29
test/cases/compile_errors/invalid_compare_string.zig
Normal file
@@ -0,0 +1,29 @@
|
||||
comptime {
|
||||
var a = "foo";
|
||||
if (a == "foo") unreachable;
|
||||
}
|
||||
comptime {
|
||||
var a = "foo";
|
||||
if (a == ("foo")) unreachable; // intentionally allow
|
||||
}
|
||||
comptime {
|
||||
var a = "foo";
|
||||
switch (a) {
|
||||
"foo" => unreachable,
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
comptime {
|
||||
var a = "foo";
|
||||
switch (a) {
|
||||
("foo") => unreachable, // intentionally allow
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:11: error: cannot compare strings with ==
|
||||
// :12:9: error: cannot switch on strings
|
||||
Reference in New Issue
Block a user