mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
29 lines
536 B
Zig
29 lines
536 B
Zig
comptime {
|
|
const a = "foo";
|
|
if (a == "foo") unreachable;
|
|
}
|
|
comptime {
|
|
const a = "foo";
|
|
if (a == ("foo")) unreachable; // intentionally allow
|
|
}
|
|
comptime {
|
|
const a = "foo";
|
|
switch (a) {
|
|
"foo" => unreachable,
|
|
else => {},
|
|
}
|
|
}
|
|
comptime {
|
|
const 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
|