summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-08-31 19:25:19 +0200
committerGitHub <noreply@github.com>2019-08-31 19:25:19 +0200
commit326a333c8b85d4cb0a8332e8ce292bf7bf296104 (patch)
tree9e77f11411e49ad05f1b478b202e00afd714f53c /tests
parent15213028b75fc485b5fd1f4461e36a04b2f0102a (diff)
parenta388c35741b4e9718ddd1d1f781a56f6bc0373c0 (diff)
downloadNim-326a333c8b85d4cb0a8332e8ce292bf7bf296104.tar.gz
Merge pull request #12099 from cooldome/destructor_too_late
fixes #12092
Diffstat (limited to 'tests')
-rw-r--r--tests/destructor/tdestructor_too_late.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/destructor/tdestructor_too_late.nim b/tests/destructor/tdestructor_too_late.nim
new file mode 100644
index 000000000..d279280ba
--- /dev/null
+++ b/tests/destructor/tdestructor_too_late.nim
@@ -0,0 +1,14 @@
+discard """
+  errmsg: "cannot bind another '=destroy' to: Obj; previous declaration was constructed here implicitly: tdestructor_too_late.nim(7, 16)"
+"""
+type Obj* = object
+  v*: int
+
+proc something(this: sink Obj) = 
+  discard
+
+proc `=destroy`(this: var Obj) =
+  echo "igotdestroyed"
+  this.v = -1
+
+var test* = Obj(v: 42)
\ No newline at end of file