summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-05-11 19:38:27 +0800
committerGitHub <noreply@github.com>2023-05-11 19:38:27 +0800
commit3b9999b93c35ff3e61b0a9848fdeb23083c89eb3 (patch)
tree8dfbca16eef724d6d276e977fc8d45b833d43449 /compiler
parentfa5e7dc44aaf0060bd72e2555c40b90bb9138730 (diff)
downloadNim-3b9999b93c35ff3e61b0a9848fdeb23083c89eb3.tar.gz
adds documentation for `=wasMoved` and `=dup` hooks and small fixes (#21827)
* adds documentation for `=wasMoved` and `=dup` hooks and small fixes

* Update doc/destructors.md

* Update doc/destructors.md

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/injectdestructors.nim4
-rw-r--r--compiler/liftdestructors.nim2
-rw-r--r--compiler/semstmts.nim2
3 files changed, 5 insertions, 3 deletions
diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim
index 9745fee81..7183aac4e 100644
--- a/compiler/injectdestructors.nim
+++ b/compiler/injectdestructors.nim
@@ -431,7 +431,9 @@ proc passCopyToSink(n: PNode; c: var Con; s: var Scope): PNode =
       let src = p(n, c, s, normal)
       result.add newTreeI(nkFastAsgn,
           src.info, tmp,
-          genOp(c, op, src)
+          newTreeIT(nkCall, src.info, src.typ,
+            newSymNode(op),
+            src)
       )
     elif typ.kind == tyRef:
       let src = p(n, c, s, normal)
diff --git a/compiler/liftdestructors.nim b/compiler/liftdestructors.nim
index 85403586f..43e5baf08 100644
--- a/compiler/liftdestructors.nim
+++ b/compiler/liftdestructors.nim
@@ -8,7 +8,7 @@
 #
 
 ## This module implements lifting for type-bound operations
-## (``=sink``, ``=copy``, ``=destroy``, ``=deepCopy``).
+## (`=sink`, `=copy`, `=destroy`, `=deepCopy`, `=wasMoved`, `=dup`).
 
 import modulegraphs, lineinfos, idents, ast, renderer, semdata,
   sighashes, lowerings, options, types, msgs, magicsys, tables, ccgutils
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 126d1aa65..f81423915 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1819,7 +1819,7 @@ proc bindTypeHook(c: PContext; s: PSym; n: PNode; op: TTypeAttachedOp) =
              of {attachedDestructor, attachedWasMoved}:
                t.len == 2 and t[0] == nil and t[1].kind == tyVar
              of attachedDup:
-               t.len == 2 and t[0] != nil and t[1].kind == tyVar
+               t.len == 2 and t[0] != nil
              of attachedTrace:
                t.len == 3 and t[0] == nil and t[1].kind == tyVar and t[2].kind == tyPointer
              else: