aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-08-07 20:08:37 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-08-07 20:08:37 -0700
commit0d5ecc4312f45f9288c4a349837f04b733405960 (patch)
treee5b61cab7f98f36025b4bbb85d9bef7239162aa5 /test/run_tests.cpp
parent275410dc33d3f040be9213d5f8175e1ced6c6a7d (diff)
downloadzig-0d5ecc4312f45f9288c4a349837f04b733405960.tar.gz
zig-0d5ecc4312f45f9288c4a349837f04b733405960.zip
ability to have a return type of 'type'
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 7941f40ab1..ea7fb0bf91 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1427,6 +1427,30 @@ fn f() {
var foo = ([]u32)(array)[0];
}
)SOURCE", 1, ".tmp_source.zig:4:22: error: unable to convert [5]u8 to []u32: size mismatch");
+
+ add_compile_fail_case("non-pure function returns type", R"SOURCE(
+var a: u32 = 0;
+pub fn List(inline T: type) -> type {
+ a += 1;
+ SmallList(T, 8)
+}
+
+pub struct SmallList(inline T: type, inline STATIC_SIZE: usize) {
+ items: []T,
+ length: usize,
+ prealloc_items: [STATIC_SIZE]T,
+}
+
+#attribute("test")
+fn function_with_return_type_type() {
+ var list: List(i32) = undefined;
+ list.length = 10;
+}
+
+ )SOURCE", 3,
+ ".tmp_source.zig:3:5: error: failed to evaluate function at compile time",
+ ".tmp_source.zig:4:5: note: unable to evaluate this expression at compile time",
+ ".tmp_source.zig:3:32: note: required to be compile-time function because of return type 'type'");
}
//////////////////////////////////////////////////////////////////////////////