diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-12-03 00:42:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-03 00:42:11 -0500 |
| commit | fdbb0fb7b9c08ebff1b7e45ef89f7160f350d44c (patch) | |
| tree | 714f2766c64ace45df1f7d67ca70be0c88193184 /test/cases/compile_errors/invalid_compare_string.zig | |
| parent | c43ac67f82cb5a022df67729aa1e6bebc22cfff2 (diff) | |
| parent | b500e0eb179218f5eb03408c09b5e5a928f0c46e (diff) | |
| download | zig-fdbb0fb7b9c08ebff1b7e45ef89f7160f350d44c.tar.gz zig-fdbb0fb7b9c08ebff1b7e45ef89f7160f350d44c.zip | |
Merge pull request #13744 from Vexu/stage2-fixes
Improve error messages, fix dependency loops
Diffstat (limited to 'test/cases/compile_errors/invalid_compare_string.zig')
| -rw-r--r-- | test/cases/compile_errors/invalid_compare_string.zig | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/cases/compile_errors/invalid_compare_string.zig b/test/cases/compile_errors/invalid_compare_string.zig new file mode 100644 index 0000000000..a5c7f041a5 --- /dev/null +++ b/test/cases/compile_errors/invalid_compare_string.zig @@ -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 |
