From 9ae426a06b2e380e688fa0b4d4ad1587bebefa64 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 26 Mar 2017 03:46:06 -0400 Subject: [PATCH] add test for implicit conversion from array to mutable slice should be a compile error closes #146 --- test/run_tests.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/run_tests.cpp b/test/run_tests.cpp index b866d5682f..27cbc6057b 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1816,6 +1816,14 @@ const Point = struct { x: i32, y: i32, }; fn foo(p: Point) { } export fn entry() -> usize { @sizeOf(@typeOf(foo)) } )SOURCE", 1, ".tmp_source.zig:3:11: error: type 'Point' is not copyable; cannot pass by value"); + + add_compile_fail_case("implicit cast from array to mutable slice", R"SOURCE( +var global_array: [10]i32 = undefined; +fn foo(param: []i32) {} +export fn entry() { + foo(global_array); +} + )SOURCE", 1, ".tmp_source.zig:5:9: error: expected type '[]i32', found '[10]i32'"); } //////////////////////////////////////////////////////////////////////////////