From 3df553ef25699d975320eb6815f0a1492261b5b2 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 5 Aug 2014 21:38:49 +0200 Subject: [PATCH] check there is only one deepCopy per type --- compiler/semstmts.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 1d913dc009..5831850487 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))