From 8ad75a9bf3a7fa9782bf17165fa6d7dc842efb51 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 24 Apr 2016 12:09:51 -0700 Subject: add compile error for invalid equality operator uses See #145 --- test/run_tests.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/run_tests.cpp') diff --git a/test/run_tests.cpp b/test/run_tests.cpp index d8f3c9a41d..09b86dc7a5 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1218,6 +1218,21 @@ fn test_a_thing() { bad_fn_call(); } )SOURCE", 1, ".tmp_source.zig:6:5: error: use of undeclared identifier 'bad_fn_call'"); + + add_compile_fail_case("illegal comparison of types", R"SOURCE( +fn bad_eql_1(a: []u8, b: []u8) -> bool { + a == b +} +enum EnumWithData { + One, + Two: i32, +} +fn bad_eql_2(a: EnumWithData, b: EnumWithData) -> bool { + a == b +} + )SOURCE", 2, + ".tmp_source.zig:3:7: error: operator not allowed for type '[]u8'", + ".tmp_source.zig:10:7: error: operator not allowed for type 'EnumWithData'"); } ////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3