aboutsummaryrefslogtreecommitdiff
path: root/tests/errors
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 08:29:46 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-14 08:29:46 +0330
commit1c53304d03414890af0da7432d1aea87e754a14a (patch)
tree97190d86cf548c9bc63f68c86a4d2a4f09809713 /tests/errors
parenta (diff)
feat: grow memory limits, add icon/actor libraries, overhaul LSP diagnostics
Compiler and VM - make every memory map limit dynamic and adjustable at both build time and runtime, including compiler tables, stacks, and every execution region - reserve and grow tables, operand and return stacks, frame segments, and image-building output without relocating live code or globals - rename i/o and string helpers consistently (puts -> put_s, putn -> put_n, scat -> cat_s) across compiler, runtime, examples, tests, and docs - recast and consume values assigned to globals from inside functions - allow fixed and const together, add typed closure returns (fn:t(...)), multi-include syntax (include rt, run, core;), and recurse type inference - never infer string literals as word, anywhere, as argument, variable, or return type - draft docs/BORROW.md: a borrow checker less intrusive than Rust's but more intelligent LSP and editor integration - require explicit includes and give every toolchain area its own namespace (rt, lsp, run, core) - hover for built-in types, inferred types, values known at hover time, array and pointer lifetime/size, library names in include statements, and inferred lifetimes with explanations - honor /* */ comments as documentation for variables and arguments, and stop misattributing section headers or trailing comments as variable hints - stream diagnostics and cancel stale requests on change - jump to definition and references, including cross-file - quick fixes with automatic library import, and namespace completion Hints and diagnostics - render hints as blue squigglies by default, with hints on/small/off per file - suppress magic-number hints via a preceding /* */ comment, and say so - warn on unused arguments; allow multiple _ discards in parameters, pattern matching, and tagged enums, warning if a _ is actually used - rewrite hint and comment prose in professional compiler-doc register Libraries - add icon.zc: run-time self-modification, find/replace syntax, type and block edits, and step-through inspection of locals and globals - add actor.zc: async actors with Actor<I,O>, implicit this, spawn/recv/send, injected into the compiler machinery at include time rather than built in Tooling and docs - reorganize sources, tests, and designs into subdirectories - unify windows entry points in tinyvm.bat and add a matching tinyvm.sh - add --help across the toolchain - polish the learning guide, stdlib docs, and design notes Tests - add accept, reject, and regression coverage across the compiler, LSP, - runtime, icon, actors, threads, formatting, and the toolchain contracts, plus fuzzers and property tests
Diffstat (limited to 'tests/errors')
-rw-r--r--tests/errors/alias_after_replace_move.zc11
-rw-r--r--tests/errors/alias_field.zc7
-rw-r--r--tests/errors/alias_index.zc9
-rw-r--r--tests/errors/alias_plus.zc5
-rw-r--r--tests/errors/alias_scope.zc5
-rw-r--r--tests/errors/array_literal_derived_return.zc5
-rw-r--r--tests/errors/array_literal_global.zc5
-rw-r--r--tests/errors/array_literal_retained.zc6
-rw-r--r--tests/errors/array_literal_return.zc5
-rw-r--r--tests/errors/back_to_m.zc5
-rw-r--r--tests/errors/borrow_escape.zc3
-rw-r--r--tests/errors/borrow_local_return.zc6
-rw-r--r--tests/errors/borrow_projection_consume.zc5
-rw-r--r--tests/errors/borrow_resize.zc10
-rw-r--r--tests/errors/branch_mismatch.zc5
-rw-r--r--tests/errors/child_dies.zc5
-rw-r--r--tests/errors/child_recast.zc5
-rw-r--r--tests/errors/copy_owned.zc5
-rw-r--r--tests/errors/d_into_block.zc5
-rw-r--r--tests/errors/d_kept.zc5
-rw-r--r--tests/errors/did_you_mean.zc2
-rw-r--r--tests/errors/discard_u.zc5
-rw-r--r--tests/errors/found_token.zc2
-rw-r--r--tests/errors/give_m.zc3
-rw-r--r--tests/errors/global_borrowed.zc7
-rw-r--r--tests/errors/global_child.zc7
-rw-r--r--tests/errors/global_store.zc3
-rw-r--r--tests/errors/global_then_use.zc6
-rw-r--r--tests/errors/leak_overwrite.zc5
-rw-r--r--tests/errors/lend_d.zc5
-rw-r--r--tests/errors/loop_move.zc5
-rw-r--r--tests/errors/old_alias_after_replace.zc11
-rw-r--r--tests/errors/plain_return.zc5
-rw-r--r--tests/errors/return_m.zc7
-rw-r--r--tests/errors/tag_mismatch.zc5
-rw-r--r--tests/errors/temporary_alias_escape.zc7
-rw-r--r--tests/errors/temporary_alias_retained.zc9
-rw-r--r--tests/errors/temporary_alias_return.zc8
-rw-r--r--tests/errors/temporary_output.zc9
-rw-r--r--tests/errors/temporary_retained.zc8
-rw-r--r--tests/errors/temporary_unknown.zc7
-rw-r--r--tests/errors/u_dropped.zc5
-rw-r--r--tests/errors/u_skip_level.zc5
-rw-r--r--tests/errors/unchecked_touch.zc5
-rw-r--r--tests/errors/unused.zc7
-rw-r--r--tests/errors/use_after_give.zc5
-rw-r--r--tests/errors/use_after_inferred_give.zc6
-rw-r--r--tests/errors/use_after_replace_move.zc10
48 files changed, 240 insertions, 46 deletions
diff --git a/tests/errors/alias_after_replace_move.zc b/tests/errors/alias_after_replace_move.zc
new file mode 100644
index 0000000..befd081
--- /dev/null
+++ b/tests/errors/alias_after_replace_move.zc
@@ -0,0 +1,11 @@
+namespace;
+include rt;
+
+// expect: borrowed: used after it was given away
+fn main() {
+ let target = rt.new(1), replacement = rt.new(1);
+ let borrowed = replacement + 0;
+ rt.free(target); target = replacement;
+ rt.put_n(target[0]);
+ return borrowed[0];
+}
diff --git a/tests/errors/alias_field.zc b/tests/errors/alias_field.zc
index 09086ca..a8d109d 100644
--- a/tests/errors/alias_field.zc
+++ b/tests/errors/alias_field.zc
@@ -1,9 +1,12 @@
+namespace;
+include rt, run;
+
// expect: c: used after it was given away
struct node { int v; node* next; };
fn main() {
- node* p = new(node), n = new(node);
+ node* p = rt.new(node), n = rt.new(node);
p.next = n;
node* c = p.next;
- free(d*p);
+ rt.free(d*p);
return c.v;
}
diff --git a/tests/errors/alias_index.zc b/tests/errors/alias_index.zc
index 3c036fe..11ce57c 100644
--- a/tests/errors/alias_index.zc
+++ b/tests/errors/alias_index.zc
@@ -1,9 +1,12 @@
+namespace;
+include rt;
+
// expect: c: used after it was given away
fn main() {
- int** list = new(int*, 2);
- int* item = new(int);
+ int** list = rt.new(int*, 2);
+ int* item = rt.new(int);
list[1] = item;
int* c = list[1];
- free(d*list);
+ rt.free(d*list);
return c[0];
}
diff --git a/tests/errors/alias_plus.zc b/tests/errors/alias_plus.zc
index d42d196..f295fa0 100644
--- a/tests/errors/alias_plus.zc
+++ b/tests/errors/alias_plus.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: q: used after it was given away
-fn main() { let p = new(2); p[0] = 1; let q = p + 0; free(d*p); return q[0]; }
+fn main() { let p = rt.new(2); p[0] = 1; let q = p + 0; rt.free(d*p); return q[0]; }
diff --git a/tests/errors/alias_scope.zc b/tests/errors/alias_scope.zc
index b51bec5..b52bfa8 100644
--- a/tests/errors/alias_scope.zc
+++ b/tests/errors/alias_scope.zc
@@ -1,6 +1,9 @@
+namespace;
+include rt;
+
// expect: q: used after it was given away
fn main() {
let q;
- { let p = new(2); q = p + 0; }
+ { let p = rt.new(2); q = p + 0; }
return q[0];
}
diff --git a/tests/errors/array_literal_derived_return.zc b/tests/errors/array_literal_derived_return.zc
new file mode 100644
index 0000000..229cdc2
--- /dev/null
+++ b/tests/errors/array_literal_derived_return.zc
@@ -0,0 +1,5 @@
+namespace;
+
+// expect: an array literal cannot escape its function through return
+fn bad() { return (int[]){1,2} + 0; }
+fn main() { return 0; }
diff --git a/tests/errors/array_literal_global.zc b/tests/errors/array_literal_global.zc
new file mode 100644
index 0000000..58d3c13
--- /dev/null
+++ b/tests/errors/array_literal_global.zc
@@ -0,0 +1,5 @@
+namespace;
+
+// expect: an array literal cannot escape into a global or container
+int* saved;
+fn main() { saved = (int[]){1,2}; return 0; }
diff --git a/tests/errors/array_literal_retained.zc b/tests/errors/array_literal_retained.zc
new file mode 100644
index 0000000..2ae9fb1
--- /dev/null
+++ b/tests/errors/array_literal_retained.zc
@@ -0,0 +1,6 @@
+namespace;
+
+// expect: a temporary argument requires a proved non-escaping borrow
+int* saved;
+fn store(int* p) { saved = p; }
+fn main() { store((int[]){1,2,3}); }
diff --git a/tests/errors/array_literal_return.zc b/tests/errors/array_literal_return.zc
new file mode 100644
index 0000000..7ccad17
--- /dev/null
+++ b/tests/errors/array_literal_return.zc
@@ -0,0 +1,5 @@
+namespace;
+
+// expect: an array literal cannot escape its function through return
+fn bad() { return (int[]){1,2}; }
+fn main() { return 0; }
diff --git a/tests/errors/back_to_m.zc b/tests/errors/back_to_m.zc
index b8c160f..34397f0 100644
--- a/tests/errors/back_to_m.zc
+++ b/tests/errors/back_to_m.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: can't be recast back to m
-fn main() { let x = new(3); d*x; m*x; return 0; }
+fn main() { let x = rt.new(3); d*x; m*x; return 0; }
diff --git a/tests/errors/borrow_escape.zc b/tests/errors/borrow_escape.zc
deleted file mode 100644
index ce24480..0000000
--- a/tests/errors/borrow_escape.zc
+++ /dev/null
@@ -1,3 +0,0 @@
-// expect: p: is owned and can't be returned
-fn f(.m p) { return p; }
-fn main() { let x = new(1); f(x); return 0; }
diff --git a/tests/errors/borrow_local_return.zc b/tests/errors/borrow_local_return.zc
new file mode 100644
index 0000000..0490b7c
--- /dev/null
+++ b/tests/errors/borrow_local_return.zc
@@ -0,0 +1,6 @@
+namespace;
+include rt;
+
+// expect: a borrow of a local owner cannot escape through return
+char* escaped() { char* p = rt.new(2); return p + 0; }
+fn main() { rt.put_s(escaped()); }
diff --git a/tests/errors/borrow_projection_consume.zc b/tests/errors/borrow_projection_consume.zc
new file mode 100644
index 0000000..913f25b
--- /dev/null
+++ b/tests/errors/borrow_projection_consume.zc
@@ -0,0 +1,5 @@
+namespace;
+include rt;
+
+// expect: a borrowed projection cannot transfer ownership
+fn main() { int* p = rt.new(int); int* alias = p + 0; rt.free(alias); rt.put_n(p[0]); }
diff --git a/tests/errors/borrow_resize.zc b/tests/errors/borrow_resize.zc
new file mode 100644
index 0000000..8594f98
--- /dev/null
+++ b/tests/errors/borrow_resize.zc
@@ -0,0 +1,10 @@
+namespace;
+include rt;
+
+// expect: element borrow was invalidated by array mutation on line 8; borrow created on line 7
+fn main() {
+ int[?] a = {1,2};
+ int* p = &a[0];
+ resize(a,3);
+ rt.put_n(p[0]);
+}
diff --git a/tests/errors/branch_mismatch.zc b/tests/errors/branch_mismatch.zc
index bd19968..ce361ac 100644
--- a/tests/errors/branch_mismatch.zc
+++ b/tests/errors/branch_mismatch.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// expect: x: ends the branches of an if in different states
fn take(.d p) { return p[0]; }
-fn main() { let x = new(1); if (x[0]) take(d*x); else u*x; return 0; }
+fn main() { let x = rt.new(1); if (x[0]) take(d*x); else u*x; return 0; }
diff --git a/tests/errors/child_dies.zc b/tests/errors/child_dies.zc
index 67caca9..defacbb 100644
--- a/tests/errors/child_dies.zc
+++ b/tests/errors/child_dies.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// expect: c: used after it was given away
fn take(.d p) { return p[0]; }
-fn main() { let p = new(2), c = new(1); p[0] = c; take(d*p); return c[0]; }
+fn main() { let p = rt.new(2), c = rt.new(1); p[0] = c; take(d*p); return c[0]; }
diff --git a/tests/errors/child_recast.zc b/tests/errors/child_recast.zc
index c9ccd62..8d44a4c 100644
--- a/tests/errors/child_recast.zc
+++ b/tests/errors/child_recast.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: c: belongs to a container; recast the container instead
-fn main() { let p = new(2), c = new(1); p[0] = c; d*c; return 0; }
+fn main() { let p = rt.new(2), c = rt.new(1); p[0] = c; d*c; return 0; }
diff --git a/tests/errors/copy_owned.zc b/tests/errors/copy_owned.zc
index 862c7ef..a56a81b 100644
--- a/tests/errors/copy_owned.zc
+++ b/tests/errors/copy_owned.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: is an owned object and can't be copied
-fn main() { let x = new(1); let y = x; return y[0]; }
+fn main() { let x = rt.new(1); let y = x; return y[0]; }
diff --git a/tests/errors/d_into_block.zc b/tests/errors/d_into_block.zc
index 2d7f526..8222674 100644
--- a/tests/errors/d_into_block.zc
+++ b/tests/errors/d_into_block.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: used after it was given away
-fn main() { let x = new(1); d*x; { x[0] = 5; } return x[0]; }
+fn main() { let x = rt.new(1); d*x; { x[0] = 5; } return x[0]; }
diff --git a/tests/errors/d_kept.zc b/tests/errors/d_kept.zc
index dcbfb86..6cd27e4 100644
--- a/tests/errors/d_kept.zc
+++ b/tests/errors/d_kept.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: d object was never given away
-fn main() { let x = new(3); d*x; x[0] = 1; return 0; }
+fn main() { let x = rt.new(3); d*x; x[0] = 1; return 0; }
diff --git a/tests/errors/did_you_mean.zc b/tests/errors/did_you_mean.zc
index 734b903..a6f6e47 100644
--- a/tests/errors/did_you_mean.zc
+++ b/tests/errors/did_you_mean.zc
@@ -1,3 +1,5 @@
+namespace;
+
// expect: did you mean 'helper'?
fn helper(x) { return x; }
fn main() { return helpr(1); }
diff --git a/tests/errors/discard_u.zc b/tests/errors/discard_u.zc
index 2743f9e..85b38c4 100644
--- a/tests/errors/discard_u.zc
+++ b/tests/errors/discard_u.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// expect: a new object (or a u result) can't be thrown away
-.u mk() { let p = new(1); return u*p; }
+.u mk() { let p = rt.new(1); return u*p; }
fn main() { mk(); return 0; }
diff --git a/tests/errors/found_token.zc b/tests/errors/found_token.zc
index 73e63dc..afd677d 100644
--- a/tests/errors/found_token.zc
+++ b/tests/errors/found_token.zc
@@ -1,2 +1,4 @@
+namespace;
+
// expect: expected ';', found 'return'
fn main() { let a = 1 return 0; }
diff --git a/tests/errors/give_m.zc b/tests/errors/give_m.zc
deleted file mode 100644
index cd67896..0000000
--- a/tests/errors/give_m.zc
+++ /dev/null
@@ -1,3 +0,0 @@
-// expect: x: is m; write d*x
-fn take(.d p) { return p[0]; }
-fn main() { let x = new(3); take(x); return 0; }
diff --git a/tests/errors/global_borrowed.zc b/tests/errors/global_borrowed.zc
new file mode 100644
index 0000000..3dc3760
--- /dev/null
+++ b/tests/errors/global_borrowed.zc
@@ -0,0 +1,7 @@
+namespace;
+include rt;
+
+// expect: p: is not an owner, so it can't be stored in a global
+let g;
+fn keep(.m p) { g = p; return 0; }
+fn main() { let x = rt.new(1); keep(x); return 0; }
diff --git a/tests/errors/global_child.zc b/tests/errors/global_child.zc
new file mode 100644
index 0000000..9b51da9
--- /dev/null
+++ b/tests/errors/global_child.zc
@@ -0,0 +1,7 @@
+namespace;
+include rt;
+
+// expect: x: is not an owner, so it can't be stored in a global
+struct box { int* v; };
+let g;
+fn main() { box* b = rt.new(box); int* x = rt.new(int); b.v = x; g = x; return 0; }
diff --git a/tests/errors/global_store.zc b/tests/errors/global_store.zc
deleted file mode 100644
index dc0e546..0000000
--- a/tests/errors/global_store.zc
+++ /dev/null
@@ -1,3 +0,0 @@
-// expect: x: must be d to be stored in a global
-let g;
-fn main() { let x = new(1); g = x; return 0; }
diff --git a/tests/errors/global_then_use.zc b/tests/errors/global_then_use.zc
new file mode 100644
index 0000000..ce01872
--- /dev/null
+++ b/tests/errors/global_then_use.zc
@@ -0,0 +1,6 @@
+namespace;
+include rt;
+
+// expect: x: used after it was given away
+let g;
+fn main() { let x = rt.new(1); g = x; return x[0]; }
diff --git a/tests/errors/leak_overwrite.zc b/tests/errors/leak_overwrite.zc
index d19b5fd..50fecfa 100644
--- a/tests/errors/leak_overwrite.zc
+++ b/tests/errors/leak_overwrite.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: still owns an object
-fn main() { let x = new(1); x = new(2); return x[0]; }
+fn main() { let x = rt.new(1); x = rt.new(2); return x[0]; }
diff --git a/tests/errors/lend_d.zc b/tests/errors/lend_d.zc
index 55ac7e0..393a314 100644
--- a/tests/errors/lend_d.zc
+++ b/tests/errors/lend_d.zc
@@ -1,4 +1,7 @@
+namespace;
+include rt;
+
// expect: x: is d; pass it to a d parameter
fn look(.m p) { return p[0]; }
fn take(.d p) { return p[0]; }
-fn main() { let x = new(3); d*x; look(x); take(x); return 0; }
+fn main() { let x = rt.new(3); d*x; look(x); take(x); return 0; }
diff --git a/tests/errors/loop_move.zc b/tests/errors/loop_move.zc
index df3c94a..17f3b4f 100644
--- a/tests/errors/loop_move.zc
+++ b/tests/errors/loop_move.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// expect: x: is given away inside a loop that comes back around to it
fn take(.d p) { return p[0]; }
-fn main() { let x = new(1); let i = 0; d*x; while (i < 3) { take(x); i++; } return 0; }
+fn main() { let x = rt.new(1); let i = 0; d*x; while (i < 3) { take(x); i++; } return 0; }
diff --git a/tests/errors/old_alias_after_replace.zc b/tests/errors/old_alias_after_replace.zc
new file mode 100644
index 0000000..7ca8616
--- /dev/null
+++ b/tests/errors/old_alias_after_replace.zc
@@ -0,0 +1,11 @@
+namespace;
+include rt;
+
+// expect: borrowed: used after it was given away
+fn main() {
+ let target = rt.new(1), replacement = rt.new(1);
+ let borrowed = target + 0;
+ rt.free(target); target = replacement;
+ rt.put_n(target[0]);
+ return borrowed[0];
+}
diff --git a/tests/errors/plain_return.zc b/tests/errors/plain_return.zc
index e23cc51..c44c533 100644
--- a/tests/errors/plain_return.zc
+++ b/tests/errors/plain_return.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// expect: is called before its body, so its owned return can't be known there
fn main() { return mk(); }
-fn mk() { return new(1); }
+fn mk() { return rt.new(1); }
diff --git a/tests/errors/return_m.zc b/tests/errors/return_m.zc
index c450711..4a6499b 100644
--- a/tests/errors/return_m.zc
+++ b/tests/errors/return_m.zc
@@ -1,3 +1,6 @@
-// expect: q: has to be u to be returned
+namespace;
+include rt;
+
+// expect: a borrowed parameter cannot be returned as an owned result
.u mk(.m q) { return q; }
-fn main() { let x = new(1); let y = mk(x); return y[0]; }
+fn main() { let x = rt.new(1); let y = mk(x); return y[0]; }
diff --git a/tests/errors/tag_mismatch.zc b/tests/errors/tag_mismatch.zc
index 079f249..1a67766 100644
--- a/tests/errors/tag_mismatch.zc
+++ b/tests/errors/tag_mismatch.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: c: its tag doesn't match its container's
-fn main() { let p = new(2), c = new(1); u*p; p[0] = c; return 0; }
+fn main() { let p = rt.new(2), c = rt.new(1); u*p; p[0] = c; return 0; }
diff --git a/tests/errors/temporary_alias_escape.zc b/tests/errors/temporary_alias_escape.zc
new file mode 100644
index 0000000..9b4c8fa
--- /dev/null
+++ b/tests/errors/temporary_alias_escape.zc
@@ -0,0 +1,7 @@
+namespace;
+include rt;
+
+// expect: a borrowed temporary cannot escape its expression
+char*.u message() { return rt.new(2); }
+char* alias(char* p) { return p; }
+fn main() { char* escaped = alias(message()) + 1; rt.put_s(escaped); }
diff --git a/tests/errors/temporary_alias_retained.zc b/tests/errors/temporary_alias_retained.zc
new file mode 100644
index 0000000..46bdfa6
--- /dev/null
+++ b/tests/errors/temporary_alias_retained.zc
@@ -0,0 +1,9 @@
+namespace;
+include rt;
+
+// expect: a temporary argument requires a proved non-escaping borrow
+char* retained;
+char*.u message() { return rt.new(2); }
+char* alias(char* p) { return p; }
+fn store(char* p) { retained = p; }
+fn main() { store(alias(message())); }
diff --git a/tests/errors/temporary_alias_return.zc b/tests/errors/temporary_alias_return.zc
new file mode 100644
index 0000000..e0ceaf5
--- /dev/null
+++ b/tests/errors/temporary_alias_return.zc
@@ -0,0 +1,8 @@
+namespace;
+include rt;
+
+// expect: a borrowed temporary cannot escape its expression through return
+char*.u message() { return rt.new(2); }
+char* alias(char* p) { return p; }
+char* escaped() { return &alias(message())[0]; }
+fn main() { rt.put_s(escaped()); }
diff --git a/tests/errors/temporary_output.zc b/tests/errors/temporary_output.zc
deleted file mode 100644
index 02a8a07..0000000
--- a/tests/errors/temporary_output.zc
+++ /dev/null
@@ -1,9 +0,0 @@
-// expect: a new object can only go straight to a d parameter; bind it to a name first
-char*.u make_text(int n) {
- let text = new(char, n);
- return u*text;
-}
-fn main() {
- put_s(make_text(3));
- return 0;
-}
diff --git a/tests/errors/temporary_retained.zc b/tests/errors/temporary_retained.zc
new file mode 100644
index 0000000..3251a65
--- /dev/null
+++ b/tests/errors/temporary_retained.zc
@@ -0,0 +1,8 @@
+namespace;
+include rt;
+
+// expect: a temporary argument requires a proved non-escaping borrow
+char* retained;
+char*.u message() { return rt.new(2); }
+fn store(char* p) { let alias = p; retained = alias; }
+fn main() { store(message()); }
diff --git a/tests/errors/temporary_unknown.zc b/tests/errors/temporary_unknown.zc
new file mode 100644
index 0000000..644e02a
--- /dev/null
+++ b/tests/errors/temporary_unknown.zc
@@ -0,0 +1,7 @@
+namespace;
+include rt;
+
+// expect: a temporary argument requires a proved non-escaping borrow
+char*.u message() { return rt.new(2); }
+unchecked fn unknown(char* p) { rt.put_s(p); }
+fn main() { unknown(message()); }
diff --git a/tests/errors/u_dropped.zc b/tests/errors/u_dropped.zc
index e1ca68a..90ccc3f 100644
--- a/tests/errors/u_dropped.zc
+++ b/tests/errors/u_dropped.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: u object must leave this block
-fn main() { let x = new(3); u*x; return 0; }
+fn main() { let x = rt.new(3); u*x; return 0; }
diff --git a/tests/errors/u_skip_level.zc b/tests/errors/u_skip_level.zc
index 6caeeb3..158e9ac 100644
--- a/tests/errors/u_skip_level.zc
+++ b/tests/errors/u_skip_level.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: t: is u; it can only be handed to a variable of the enclosing block
-fn main() { let r; { { let t = new(1); u*t; r = t; } } return r[0]; }
+fn main() { let r; { { let t = rt.new(1); u*t; r = t; } } return r[0]; }
diff --git a/tests/errors/unchecked_touch.zc b/tests/errors/unchecked_touch.zc
index 141639d..b2e0edf 100644
--- a/tests/errors/unchecked_touch.zc
+++ b/tests/errors/unchecked_touch.zc
@@ -1,2 +1,5 @@
+namespace;
+include rt;
+
// expect: x: is tracked by the analyzer and can't be used in unchecked code
-fn main() { let x = new(1); unchecked { x[0] = 1; } return 0; }
+fn main() { let x = rt.new(1); unchecked { x[0] = 1; } return 0; }
diff --git a/tests/errors/unused.zc b/tests/errors/unused.zc
index 64aff1f..5c88ce3 100644
--- a/tests/errors/unused.zc
+++ b/tests/errors/unused.zc
@@ -1,2 +1,5 @@
-// expect: x: m object is never used
-fn main() { let x = new(3); return 0; }
+namespace;
+include rt;
+
+// expect: x is never read
+fn main() { let x = rt.new(3); return 0; }
diff --git a/tests/errors/use_after_give.zc b/tests/errors/use_after_give.zc
index 8a10922..72d3444 100644
--- a/tests/errors/use_after_give.zc
+++ b/tests/errors/use_after_give.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// expect: x: used after it was given away
fn take(.d p) { return p[0]; }
-fn main() { let x = new(3); take(d*x); return x[0]; }
+fn main() { let x = rt.new(3); take(d*x); return x[0]; }
diff --git a/tests/errors/use_after_inferred_give.zc b/tests/errors/use_after_inferred_give.zc
new file mode 100644
index 0000000..19841cb
--- /dev/null
+++ b/tests/errors/use_after_inferred_give.zc
@@ -0,0 +1,6 @@
+namespace;
+include rt;
+
+// expect: x: used after it was given away; owner x was transferred on line 6 (declared on line 6)
+fn take(.d p) { return p[0]; }
+fn main() { let x = rt.new(3); take(x); return x[0]; }
diff --git a/tests/errors/use_after_replace_move.zc b/tests/errors/use_after_replace_move.zc
new file mode 100644
index 0000000..81f5833
--- /dev/null
+++ b/tests/errors/use_after_replace_move.zc
@@ -0,0 +1,10 @@
+namespace;
+include rt;
+
+// expect: replacement: used after it was given away
+fn main() {
+ let target = rt.new(1), replacement = rt.new(1);
+ rt.free(target); target = replacement;
+ rt.put_n(target[0]);
+ return replacement[0];
+}