diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-23 11:53:05 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-23 11:53:05 -0400 |
| commit | 9ec6a78f121c8f61c10ea02f6949f27b0228ba16 (patch) | |
| tree | e08bf750cfd8181fff72d52d20139e6cd6a805b7 /test/run_tests.cpp | |
| parent | 46eb77dbb200756b96bfae4c5166397fefba66d0 (diff) | |
| download | zig-9ec6a78f121c8f61c10ea02f6949f27b0228ba16.tar.gz zig-9ec6a78f121c8f61c10ea02f6949f27b0228ba16.zip | |
fix compiler crash for misspelled type with pointer only reference
closes #196
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index bbf1fd2168..4f86519879 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1501,6 +1501,39 @@ fn foo(blah: []u8) { for (blah) { } } )SOURCE", 1, ".tmp_source.zig:3:16: error: for loop expression missing element parameter"); + + add_compile_fail_case("misspelled type with pointer only reference", R"SOURCE( +const JasonHM = u8; +const JasonList = &JsonNode; + +enum JsonOA { + JSONArray: JsonList, + JSONObject: JasonHM, +} + +enum JsonType { + JSONNull: void, + JSONInteger: isize, + JSONDouble: f64, + JSONBool: bool, + JSONString: []u8, + JSONArray, + JSONObject, +} + +pub struct JsonNode { + kind: JsonType, + jobject: ?JsonOA, +} + +fn foo() { + var jll: JasonList = undefined; + jll.init(&debug.global_allocator); + var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} }; +} + )SOURCE", 2, + ".tmp_source.zig:6:16: error: use of undeclared identifier 'JsonList'", + ".tmp_source.zig:27:8: error: no function named 'init' in 'JsonNode'"); } ////////////////////////////////////////////////////////////////////////////// |
