summary refs log tree commit diff stats
path: root/tests/system/tensuremove1.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-07-29 16:57:03 +0800
committerGitHub <noreply@github.com>2023-07-29 10:57:03 +0200
commitf0f3904ff04a46bae6f876b0326162354466f415 (patch)
treec83cd3d31c646221488c82e90fd48461d5028c5c /tests/system/tensuremove1.nim
parentf1ac979184ad7fa0d8c44415e781181a00a0095f (diff)
downloadNim-f0f3904ff04a46bae6f876b0326162354466f415.tar.gz
implement `ensureMove` (#22339)
* implement `ensureMove`

* use an additional flag

* improve some logics

* progress: fixes discard ensureMove

* forbids nested expressions

* improve error messages

* checkpoint

* fixes cursor

* ADD MORE TESTS

* fixes cursorinference again

* tiny cleanup

* improve error messages

* fixes docs

* implement comments add more tests

* fixes js
Diffstat (limited to 'tests/system/tensuremove1.nim')
-rw-r--r--tests/system/tensuremove1.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/system/tensuremove1.nim b/tests/system/tensuremove1.nim
new file mode 100644
index 000000000..b7e19c4fb
--- /dev/null
+++ b/tests/system/tensuremove1.nim
@@ -0,0 +1,16 @@
+discard """
+  errormsg: "cannot move 's', which introduces an implicit copy"
+  matrix: "--cursorinference:on; --cursorinference:off"
+"""
+
+type
+  String = object
+    id: string
+
+proc hello =
+  var s = String(id: "1")
+  var m = ensureMove s
+  discard m
+  discard s
+
+hello()
\ No newline at end of file