diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-03-23 00:12:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-23 00:12:05 +0100 |
commit | bf592c4e944e9cca8a2bb60f52b5b39388c4ed4c (patch) | |
tree | f5a7eddcae6fca19dd785a975e2f885f88ff8007 /tests/destructor | |
parent | 25649616ea5b6aba575149df3f9943f48a5ece31 (diff) | |
download | Nim-bf592c4e944e9cca8a2bb60f52b5b39388c4ed4c.tar.gz |
more destructor based changes (#10885)
* mark user defined destructors with sfOverriden to simplify the logic * refactoring in preparation to merge liftings and generic instantiations for destructors * ast: introduce nkHiddenTryStmt for destructor generation in order to be able to optimize better the code later on * renamed 'patterns' switch to 'trmacros' as it was totally misleading before * destructors: introduce tfCheckedForDestructor flag in preparation of strict =destroy checking * test for invalid/too late destructor introductions * liftdestructors: make code robust for nimsuggest * --newruntime works for hello world again * newruntime: code generation for closures
Diffstat (limited to 'tests/destructor')
-rw-r--r-- | tests/destructor/tinvalid_rebind.nim | 15 | ||||
-rw-r--r-- | tests/destructor/topttree.nim | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/destructor/tinvalid_rebind.nim b/tests/destructor/tinvalid_rebind.nim new file mode 100644 index 000000000..0f15c8f9e --- /dev/null +++ b/tests/destructor/tinvalid_rebind.nim @@ -0,0 +1,15 @@ +discard """ +joinable: false +cmd: "nim check $file" +errormsg: "cannot bind another '=destroy' to: Foo; previous declaration was constructed here implicitly: tinvalid_rebind.nim(12, 7)" +line: 14 +""" + +type + Foo[T] = object + +proc main = + var f: Foo[int] + +proc `=destroy`[T](f: var Foo[T]) = + discard diff --git a/tests/destructor/topttree.nim b/tests/destructor/topttree.nim index 90ac6fa27..fa5495689 100644 --- a/tests/destructor/topttree.nim +++ b/tests/destructor/topttree.nim @@ -22,6 +22,7 @@ var proc `=destroy`*[T](x: var opt[T]) = if x.data != nil: + mixin `=destroy` when not supportsCopyMem(T): `=destroy`(x.data[]) dealloc(x.data) |