aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-15 02:37:04 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-15 02:40:51 +0330
commitb02bdd043673419357eadd6c646b9a77c62e5792 (patch)
tree629a8b700ecf64f19d70d2a6b00aa3eb79ade004 /tests
parentdestructors: nothing moves out of a value with a drop: pop on an array with a... (diff)
destructors: hint: x: has drop and is live at spawn; the worker's copy drops it too, on x.spawn() of a mailbox struct for each live owned local with a drop; spec 6.15.4, lsp hint check
Diffstat (limited to 'tests')
-rw-r--r--tests/data/spawn_hint.zc11
-rwxr-xr-xtests/test.sh1
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/data/spawn_hint.zc b/tests/data/spawn_hint.zc
new file mode 100644
index 0000000..b59657d
--- /dev/null
+++ b/tests/data/spawn_hint.zc
@@ -0,0 +1,11 @@
+namespace;
+include rt, actor;
+struct res { int fd; void drop() { rt.put_s("closed"); } }
+actor Echo { int total; int handle(int x) { return x; } }
+fn main() {
+ res* r = rt.new(res); r.fd = 3;
+ Echo* e = rt.new(Echo);
+ e.spawn();
+ e.close();
+ return r.fd;
+}
diff --git a/tests/test.sh b/tests/test.sh
index 9aee6d0..6dfecf1 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -580,6 +580,7 @@ s_lsp() {
chk "$($lsp < examples/struct_closure_opt.zc | grep -c error)" "0" "lsp: methods and closures check clean"
case "$($lsp < tests/data/drop_hint.zc)" in *"value with drop is never bound; it drops at the end of this statement"*) chk 1 1 "lsp hint: a value with drop that is never bound";; *) chk 0 1 "lsp hint: a value with drop that is never bound";; esac
case "$($lsp < tests/data/reassign_hint.zc)" in *"p: reassigning frees the old value"*) chk 1 1 "lsp hint: reassigning an owner frees the old value";; *) chk 0 1 "lsp hint: reassigning an owner frees the old value";; esac
+ case "$($lsp < tests/data/spawn_hint.zc)" in *"r: has drop and is live at spawn; the worker's copy drops it too"*) chk 1 1 "lsp hint: a value with drop live at spawn";; *) chk 0 1 "lsp hint: a value with drop live at spawn";; esac
# a file of a larger build checks on its own: its bodyless declarations are not errors in check mode
for f in src/runtime/rt.zc src/runtime/run.zc src/lsp/server.zc; do chk "$($lsp < $f | grep -c ': error:')" "0" "lsp: $f checks alone"; done
# the compiler is several files that only make sense together: check them as one document