From fc100d7b3b27bd514dca4e02c160e5b96d4da648 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 9 Feb 2017 02:50:03 -0500 Subject: lots of miscellaneous things all in one big commit * add `@compileLog(...)` builtin function - Helps debug code running at compile time - See #240 * fix crash when there is an error on the start value of a slice * add implicit cast from int and float types to int and float literals if the value is known at compile time * make array concatenation work with slices in addition to arrays and c string literals * fix compile error message for something not having field access * fix crash when `@setDebugSafety()` was called from a function being evaluated at compile-time * fix compile-time evaluation of overflow math builtins. * avoid debug safety panic handler in builtin.o and compiler_rt.o since we use no debug safety in these modules anyway * add compiler_rt functions for division on ARM - Closes #254 * move default panic handler to std.debug so users can call it manually * std.io.printf supports a width in the format specifier --- test/run_tests.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'test/run_tests.cpp') diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 01d16a2543..828f3469bf 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1015,8 +1015,9 @@ const x = foo(); add_compile_fail_case("array concatenation with wrong type", R"SOURCE( const src = "aoeu"; -const a = src[0...] ++ "foo"; - )SOURCE", 1, ".tmp_source.zig:3:14: error: expected array or C string literal, found '[]u8'"); +const derp = usize(1234); +const a = derp ++ "foo"; + )SOURCE", 1, ".tmp_source.zig:4:11: error: expected array or C string literal, found 'usize'"); add_compile_fail_case("non compile time array concatenation", R"SOURCE( fn f(s: [10]u8) -> []u8 { @@ -1632,6 +1633,23 @@ const some_data: [100]u8 = { }; )SOURCE", 1, ".tmp_source.zig:3:32: error: alignment value must be power of 2"); + add_compile_fail_case("compile log", R"SOURCE( +fn foo() { + comptime bar(12, "hi"); +} +fn bar(a: i32, b: []const u8) { + @compileLog("begin"); + @compileLog("a", a, "b", b); + @compileLog("end"); +} + )SOURCE", 6, + ".tmp_source.zig:6:5: error: found compile log statement", + ".tmp_source.zig:3:17: note: called from here", + ".tmp_source.zig:7:5: error: found compile log statement", + ".tmp_source.zig:3:17: note: called from here", + ".tmp_source.zig:8:5: error: found compile log statement", + ".tmp_source.zig:3:17: note: called from here"); + } ////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3