diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-16 16:07:03 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-16 16:07:03 -0500 |
| commit | 867686af420bab965f63359499a526f35e875c9a (patch) | |
| tree | 081d9129e01e9dd3953a3a65c9856cf56b77cbcd /test/run_tests.cpp | |
| parent | fdbc2d8da1c707859af8f8bb42a27ae9d3a62159 (diff) | |
| download | zig-867686af420bab965f63359499a526f35e875c9a.tar.gz zig-867686af420bab965f63359499a526f35e875c9a.zip | |
equality comparison of void types is known at compile time
closes #56
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index bd551d9294..7e616e0986 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1605,6 +1605,25 @@ fn derp() { } )SOURCE", 1, ".tmp_source.zig:7:13: error: cannot assign to constant"); + add_compile_fail_case("compare void with void is compile time known", R"SOURCE( +const Foo = struct { + a: void, + b: i32, + c: void, +}; + +fn f() { + const foo = Foo { + .a = {}, + .b = 1, + .c = {}, + }; + if (foo.a != {}) { + @unreachable(); + } +} + )SOURCE", 1, ".tmp_source.zig:14:15: error: condition is always false; unnecessary if statement"); + } ////////////////////////////////////////////////////////////////////////////// |
