summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-08-05 21:38:49 +0200
committerAraq <rumpf_a@web.de>2014-08-05 21:38:49 +0200
commit3df553ef25699d975320eb6815f0a1492261b5b2 (patch)
tree9dc9b8a7b3dc976e3ea2240074f7328ec0847eaa /compiler/semstmts.nim
parent053b34d91d5dd7d57cb3878a1286b351c67b217c (diff)
downloadNim-3df553ef25699d975320eb6815f0a1492261b5b2.tar.gz
check there is only one deepCopy per type
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 1d913dc00..583185048 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1020,7 +1020,10 @@ proc semOverride(c: PContext, s: PSym, n: PNode) =
       # the problem that pointers are structural types:
       let t = s.typ.sons[1].skipTypes(abstractInst).lastSon.skipTypes(abstractInst)
       if t.kind in {tyObject, tyDistinct, tyEnum}:
-        t.deepCopy = s
+        if t.deepCopy.isNil: t.deepCopy = s
+        else: 
+          localError(n.info, errGenerated,
+                     "cannot bind another 'deepCopy' to: " & typeToString(t))
       else:
         localError(n.info, errGenerated,
                    "cannot bind 'deepCopy' to: " & typeToString(t))