better array concatenation semantics

closes #87
This commit is contained in:
Andrew Kelley
2016-05-07 10:05:59 -07:00
parent d5d5fd928c
commit 8c79438f6b
9 changed files with 103 additions and 44 deletions

View File

@@ -999,11 +999,17 @@ extern fn foo() -> i32;
const x = foo();
)SOURCE", 1, ".tmp_source.zig:3:11: error: global variable initializer requires constant expression");
add_compile_fail_case("non compile time string concatenation", R"SOURCE(
add_compile_fail_case("array concatenation with wrong type", R"SOURCE(
fn f(s: []u8) -> []u8 {
s ++ "foo"
}
)SOURCE", 1, ".tmp_source.zig:3:5: error: string concatenation requires constant expression");
)SOURCE", 1, ".tmp_source.zig:3:5: error: expected array or C string literal, got '[]u8'");
add_compile_fail_case("non compile time array concatenation", R"SOURCE(
fn f(s: [10]u8) -> []u8 {
s ++ "foo"
}
)SOURCE", 1, ".tmp_source.zig:3:5: error: array concatenation requires constant expression");
add_compile_fail_case("c_import with bogus include", R"SOURCE(
const c = @c_import(@c_include("bogus.h"));