authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-03-26 03:46:06-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-03-26 03:46:06-04:00
log9ae426a06b2e380e688fa0b4d4ad1587bebefa64
tree8126fb13f27b403a930469da86e861ed7298140a
parent7c53230a61568411e1375e1230df1ceaf1e462de

add test for implicit conversion from array to mutable slice

should be a compile error closes #146

1 files changed, 8 insertions(+), 0 deletions(-)

test/run_tests.cpp+8
...@@ -1816,6 +1816,14 @@ const Point = struct { x: i32, y: i32, };...@@ -1816,6 +1816,14 @@ const Point = struct { x: i32, y: i32, };
1816fn foo(p: Point) { }1816fn foo(p: Point) { }
1817export fn entry() -> usize { @sizeOf(@typeOf(foo)) }1817export fn entry() -> usize { @sizeOf(@typeOf(foo)) }
1818 )SOURCE", 1, ".tmp_source.zig:3:11: error: type 'Point' is not copyable; cannot pass by value");1818 )SOURCE", 1, ".tmp_source.zig:3:11: error: type 'Point' is not copyable; cannot pass by value");
1819
1820 add_compile_fail_case("implicit cast from array to mutable slice", R"SOURCE(
1821var global_array: [10]i32 = undefined;
1822fn foo(param: []i32) {}
1823export fn entry() {
1824 foo(global_array);
1825}
1826 )SOURCE", 1, ".tmp_source.zig:5:9: error: expected type '[]i32', found '[10]i32'");
1819}1827}
18201828
1821//////////////////////////////////////////////////////////////////////////////1829//////////////////////////////////////////////////////////////////////////////