summary refs log tree commit diff stats
path: root/compiler/semmagic.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-10-17 21:59:17 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-10-17 21:59:17 +0200
commite7f37d7223920939cda1a206cc84efee41952437 (patch)
treec5f28ec00c2ee0ea8a2ae23851559e9a1f663abf /compiler/semmagic.nim
parent58d5f9679028516b09bc2a2c0498e668f61cc8c9 (diff)
downloadNim-e7f37d7223920939cda1a206cc84efee41952437.tar.gz
added typetraits.supportsCopyMem
Diffstat (limited to 'compiler/semmagic.nim')
-rw-r--r--compiler/semmagic.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 8b3d9c014..88f1262ae 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -146,8 +146,13 @@ proc evalTypeTrait(traitCall: PNode, operand: PType, context: PSym): PNode =
     result = res.base.toNode(traitCall.info)
   of "stripGenericParams":
     result = uninstantiate(operand).toNode(traitCall.info)
+  of "supportsCopyMem":
+    let complexObj = containsGarbageCollectedRef(operand) or
+                     hasDestructor(operand)
+    result = newIntNodeT(ord(not complexObj), traitCall)
   else:
-    internalAssert false
+    localError(traitCall.info, "unknown trait")
+    result = emptyNode
 
 proc semTypeTraits(c: PContext, n: PNode): PNode =
   checkMinSonsLen(n, 2)