summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-01-19 13:26:15 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-01-19 13:26:22 +0100
commitb85898cd416c6ccdfbfea0eb3d0b2d2c03552f3d (patch)
tree4411bed5a22c10a059739a9e76badcbaaeb63bc7
parent4ec0f9305e99cfc3193bca2b0ca6b2df69bd173d (diff)
downloadNim-b85898cd416c6ccdfbfea0eb3d0b2d2c03552f3d.tar.gz
fixes #5237
-rw-r--r--compiler/transf.nim5
-rw-r--r--tests/vm/textensionmap.nim13
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index ee05b6e43..4208c43e5 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -679,7 +679,7 @@ proc transformCall(c: PTransf, n: PNode): PTransNode =
           inc(j)
       add(result, a.PTransNode)
     if len(result) == 2: result = result[1]
-  elif magic == mNBindSym:
+  elif magic in {mNBindSym, mTypeOf}:
     # for bindSym(myconst) we MUST NOT perform constant folding:
     result = n.PTransNode
   elif magic == mProcCall:
@@ -820,7 +820,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
   of nkConstSection:
     # do not replace ``const c = 3`` with ``const 3 = 3``
     return transformConstSection(c, n)
-  of nkTypeSection:
+  of nkTypeSection, nkTypeOfExpr:
     # no need to transform type sections:
     return PTransNode(n)
   of nkVarSection, nkLetSection:
@@ -851,6 +851,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
     result = transformSons(c, n)
   when false:
     if oldDeferAnchor != nil: c.deferAnchor = oldDeferAnchor
+
   var cnst = getConstExpr(c.module, PNode(result))
   # we inline constants if they are not complex constants:
   if cnst != nil and not dontInlineConstant(n, cnst):
diff --git a/tests/vm/textensionmap.nim b/tests/vm/textensionmap.nim
new file mode 100644
index 000000000..5d4b25d01
--- /dev/null
+++ b/tests/vm/textensionmap.nim
@@ -0,0 +1,13 @@
+
+# bug #5237
+
+import tables
+import sets
+import sequtils
+
+
+const EXTENSIONMAP = {
+  "c": @["*.c", "*.h"],
+}.toTable()
+
+const EXTENSIONS = toSet(concat(toSeq(EXTENSIONMAP.values())))