summary refs log tree commit diff stats
path: root/compiler/lambdalifting.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-06-05 13:04:02 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-06-05 13:04:02 +0200
commit62376c065733340f5f62b58556e26e9b3ec5a2f0 (patch)
treed823b78700d3fd46d63d6f8b7af1bd6de244a81b /compiler/lambdalifting.nim
parentf8326ad4c047f5d45817d0424dfb0b17aa17b538 (diff)
parentc5f7d553e969bd90223570059c199c8459b16a54 (diff)
downloadNim-62376c065733340f5f62b58556e26e9b3ec5a2f0.tar.gz
Merge pull request #2824 from yglukhov/js-ct-lambda-lifting
Perform lambda lifting for compile-time stuff when targeting JS.
Diffstat (limited to 'compiler/lambdalifting.nim')
-rw-r--r--compiler/lambdalifting.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim
index c68bc352c..69b45c980 100644
--- a/compiler/lambdalifting.nim
+++ b/compiler/lambdalifting.nim
@@ -946,7 +946,11 @@ proc transformOuterProc(o: POuterContext, n: PNode; it: TIter): PNode =
 proc liftLambdas*(fn: PSym, body: PNode): PNode =
   # XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs
   # the transformation even when compiling to JS ...
-  if body.kind == nkEmpty or gCmd == cmdCompileToJS or
+
+  # However we can do lifting for the stuff which is *only* compiletime.
+  let isCompileTime = sfCompileTime in fn.flags or fn.kind == skMacro
+
+  if body.kind == nkEmpty or (gCmd == cmdCompileToJS and not isCompileTime) or
       fn.skipGenericOwner.kind != skModule:
     # ignore forward declaration:
     result = body