diff options
author | cooldome <cdome@bk.ru> | 2019-01-18 07:51:22 +0000 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-01-18 08:51:22 +0100 |
commit | 1e63f1edb3fa594bcdce39eb5195d5f5d2644e67 (patch) | |
tree | 04b8bf5530b2b8960ed890d3f34a1aead417453b /tests/destructor | |
parent | 214f48eae9b6a02d5ba68ddf0b1e6b9a26bddacb (diff) | |
download | Nim-1e63f1edb3fa594bcdce39eb5195d5f5d2644e67.tar.gz |
destructors: first step towards fixing #9617 (#10341)
Diffstat (limited to 'tests/destructor')
-rw-r--r-- | tests/destructor/helper.nim | 3 | ||||
-rw-r--r-- | tests/destructor/terror_module.nim | 20 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/destructor/helper.nim b/tests/destructor/helper.nim new file mode 100644 index 000000000..466065747 --- /dev/null +++ b/tests/destructor/helper.nim @@ -0,0 +1,3 @@ +type + MyTestObject*[T] = object + p: ptr T diff --git a/tests/destructor/terror_module.nim b/tests/destructor/terror_module.nim new file mode 100644 index 000000000..f3d7c9b26 --- /dev/null +++ b/tests/destructor/terror_module.nim @@ -0,0 +1,20 @@ +discard """ +joinable: false +cmd: "nim check $file" +errormsg: "type bound operation `=deepcopy` can be defined only in the same module with its type (MyTestObject)" +nimout: ''' +terror_module.nim(14, 1) Error: type bound operation `=destroy` can be defined only in the same module with its type (MyTestObject) +terror_module.nim(16, 1) Error: type bound operation `=sink` can be defined only in the same module with its type (MyTestObject) +terror_module.nim(18, 1) Error: type bound operation `=` can be defined only in the same module with its type (MyTestObject) +terror_module.nim(20, 1) Error: type bound operation `=deepcopy` can be defined only in the same module with its type (MyTestObject) +''' +""" +import helper + +proc `=destroy`[T](x: var MyTestObject[T]) = discard + +proc `=sink`[T](x: var MyTestObject[T], y:MyTestObject[T]) = discard + +proc `=`[T](x: var MyTestObject[T], y: MyTestObject[T]) = discard + +proc `=deepcopy`[T](x: ptr MyTestObject[T]): ptr MyTestObject[T] = discard |