diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-02 20:13:10 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-02 20:13:10 -0700 |
| commit | 258bc73eee557ada944c9d25ed85d9baf8035ad7 (patch) | |
| tree | d34d6cca4d4f91a6938ff27fb5eb55c9b7ce1915 /test/run_tests.cpp | |
| parent | 187d00ca835d2c923cbc0a3ab9e861e82888d403 (diff) | |
| download | zig-258bc73eee557ada944c9d25ed85d9baf8035ad7.tar.gz zig-258bc73eee557ada944c9d25ed85d9baf8035ad7.zip | |
fix implicit cast after unreachable bad code gen
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 839109a1ab..645d8295fa 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -682,6 +682,21 @@ export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { return 0; } )SOURCE", "x is true\n"); + + add_simple_case("implicit cast after unreachable", R"SOURCE( +use "std.zig"; +export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 { + const x = outer(); + if (x == 1234) { + print_str("OK\n"); + } + return 0; +} +fn inner() -> i32 { 1234 } +fn outer() -> isize { + return inner(); +} + )SOURCE", "OK\n"); } //////////////////////////////////////////////////////////////////////////////////// @@ -978,6 +993,12 @@ fn f() { if (const x ?= true) { } } )SOURCE", 1, ".tmp_source.zig:3:20: error: expected maybe type"); + + add_compile_fail_case("cast unreachable", R"SOURCE( +fn f() -> i32 { + (return 1) as i32 +} + )SOURCE", 1, ".tmp_source.zig:3:16: error: invalid cast from type 'unreachable' to 'i32'"); } static void print_compiler_invocation(TestCase *test_case) { |
