aboutsummaryrefslogtreecommitdiff
path: root/tests/errors/borrows_body.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/errors/borrows_body.zc')
-rw-r--r--tests/errors/borrows_body.zc13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/errors/borrows_body.zc b/tests/errors/borrows_body.zc
new file mode 100644
index 0000000..e6c92c6
--- /dev/null
+++ b/tests/errors/borrows_body.zc
@@ -0,0 +1,13 @@
+namespace;
+include rt;
+
+// expect: first: returns a borrow of b, but its borrows clause doesn't name it
+// the body is checked against the prototype's borrows clause.
+char* first(char* a, char* b) borrows a;
+fn main() {
+ char* t = rt.new(4); t[0] = 'x'; t[1] = 0;
+ char* u = rt.new(4); u[0] = 'y'; u[1] = 0;
+ let r = first(t, u); rt.put_c(r[0]); rt.free(u); rt.free(t);
+ return 0;
+}
+char* first(char* a, char* b) { return b; }