diff options
Diffstat (limited to 'docs/history/13-gap-fixes/code/tests/errors')
22 files changed, 56 insertions, 0 deletions
diff --git a/docs/history/13-gap-fixes/code/tests/errors/back_to_m.zc b/docs/history/13-gap-fixes/code/tests/errors/back_to_m.zc new file mode 100644 index 0000000..b8c160f --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/back_to_m.zc @@ -0,0 +1,2 @@ +// expect: x: can't be recast back to m +fn main() { let x = new(3); d*x; m*x; return 0; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/borrow_escape.zc b/docs/history/13-gap-fixes/code/tests/errors/borrow_escape.zc new file mode 100644 index 0000000..ce24480 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/borrow_escape.zc @@ -0,0 +1,3 @@ +// 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/docs/history/13-gap-fixes/code/tests/errors/branch_mismatch.zc b/docs/history/13-gap-fixes/code/tests/errors/branch_mismatch.zc new file mode 100644 index 0000000..bd19968 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/branch_mismatch.zc @@ -0,0 +1,3 @@ +// 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; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/child_dies.zc b/docs/history/13-gap-fixes/code/tests/errors/child_dies.zc new file mode 100644 index 0000000..67caca9 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/child_dies.zc @@ -0,0 +1,3 @@ +// 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]; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/child_recast.zc b/docs/history/13-gap-fixes/code/tests/errors/child_recast.zc new file mode 100644 index 0000000..c9ccd62 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/child_recast.zc @@ -0,0 +1,2 @@ +// 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; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/copy_owned.zc b/docs/history/13-gap-fixes/code/tests/errors/copy_owned.zc new file mode 100644 index 0000000..862c7ef --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/copy_owned.zc @@ -0,0 +1,2 @@ +// expect: x: is an owned object and can't be copied +fn main() { let x = new(1); let y = x; return y[0]; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/d_into_block.zc b/docs/history/13-gap-fixes/code/tests/errors/d_into_block.zc new file mode 100644 index 0000000..2d7f526 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/d_into_block.zc @@ -0,0 +1,2 @@ +// expect: x: used after it was given away +fn main() { let x = new(1); d*x; { x[0] = 5; } return x[0]; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/d_kept.zc b/docs/history/13-gap-fixes/code/tests/errors/d_kept.zc new file mode 100644 index 0000000..dcbfb86 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/d_kept.zc @@ -0,0 +1,2 @@ +// expect: x: d object was never given away +fn main() { let x = new(3); d*x; x[0] = 1; return 0; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/discard_u.zc b/docs/history/13-gap-fixes/code/tests/errors/discard_u.zc new file mode 100644 index 0000000..dd76e94 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/discard_u.zc @@ -0,0 +1,3 @@ +// expect: can't be thrown away +fn mk() -> .u { let p = new(1); return u*p; } +fn main() { mk(); return 0; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/give_m.zc b/docs/history/13-gap-fixes/code/tests/errors/give_m.zc new file mode 100644 index 0000000..cd67896 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/give_m.zc @@ -0,0 +1,3 @@ +// 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/docs/history/13-gap-fixes/code/tests/errors/global_store.zc b/docs/history/13-gap-fixes/code/tests/errors/global_store.zc new file mode 100644 index 0000000..dc0e546 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/global_store.zc @@ -0,0 +1,3 @@ +// 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/docs/history/13-gap-fixes/code/tests/errors/leak_overwrite.zc b/docs/history/13-gap-fixes/code/tests/errors/leak_overwrite.zc new file mode 100644 index 0000000..d19b5fd --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/leak_overwrite.zc @@ -0,0 +1,2 @@ +// expect: x: still owns an object +fn main() { let x = new(1); x = new(2); return x[0]; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/lend_d.zc b/docs/history/13-gap-fixes/code/tests/errors/lend_d.zc new file mode 100644 index 0000000..55ac7e0 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/lend_d.zc @@ -0,0 +1,4 @@ +// 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; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/loop_move.zc b/docs/history/13-gap-fixes/code/tests/errors/loop_move.zc new file mode 100644 index 0000000..df3c94a --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/loop_move.zc @@ -0,0 +1,3 @@ +// 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; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/plain_return.zc b/docs/history/13-gap-fixes/code/tests/errors/plain_return.zc new file mode 100644 index 0000000..4540714 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/plain_return.zc @@ -0,0 +1,3 @@ +// expect: returns a new object; declare the function with -> .u +fn mk() { return new(1); } +fn main() { return mk(); } diff --git a/docs/history/13-gap-fixes/code/tests/errors/return_m.zc b/docs/history/13-gap-fixes/code/tests/errors/return_m.zc new file mode 100644 index 0000000..1acc4be --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/return_m.zc @@ -0,0 +1,3 @@ +// expect: x: has to be u to be returned +fn mk() -> .u { let x = new(1); return x; } +fn main() { let y = mk(); return y[0]; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/tag_mismatch.zc b/docs/history/13-gap-fixes/code/tests/errors/tag_mismatch.zc new file mode 100644 index 0000000..079f249 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/tag_mismatch.zc @@ -0,0 +1,2 @@ +// 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; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/u_dropped.zc b/docs/history/13-gap-fixes/code/tests/errors/u_dropped.zc new file mode 100644 index 0000000..e1ca68a --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/u_dropped.zc @@ -0,0 +1,2 @@ +// expect: x: u object must leave this block +fn main() { let x = new(3); u*x; return 0; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/u_skip_level.zc b/docs/history/13-gap-fixes/code/tests/errors/u_skip_level.zc new file mode 100644 index 0000000..6caeeb3 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/u_skip_level.zc @@ -0,0 +1,2 @@ +// 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]; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/unchecked_touch.zc b/docs/history/13-gap-fixes/code/tests/errors/unchecked_touch.zc new file mode 100644 index 0000000..141639d --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/unchecked_touch.zc @@ -0,0 +1,2 @@ +// 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; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/unused.zc b/docs/history/13-gap-fixes/code/tests/errors/unused.zc new file mode 100644 index 0000000..64aff1f --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/unused.zc @@ -0,0 +1,2 @@ +// expect: x: m object is never used +fn main() { let x = new(3); return 0; } diff --git a/docs/history/13-gap-fixes/code/tests/errors/use_after_give.zc b/docs/history/13-gap-fixes/code/tests/errors/use_after_give.zc new file mode 100644 index 0000000..8a10922 --- /dev/null +++ b/docs/history/13-gap-fixes/code/tests/errors/use_after_give.zc @@ -0,0 +1,3 @@ +// 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]; } |
