From 8f35bca839d9601f0ccb762f44703529eb86b89d Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Mon, 9 Nov 2020 18:46:25 +0800 Subject: [PATCH] fix #12558 (#15864) * fix #12558 * Update compiler/pragmas.nim (cherry picked from commit 673c5990c6b2130dd3b1a4854eb5d85c73a90cd0) --- compiler/pragmas.nim | 6 +++++- tests/pragmas/t12558.nim | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/pragmas/t12558.nim diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 5eb90efe96..dfec1d5fe3 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -896,7 +896,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, of wMagic: processMagic(c, it, sym) of wCompileTime: noVal(c, it) - incl(sym.flags, sfCompileTime) + if comesFromPush: + if sym.kind in {skProc, skFunc}: + incl(sym.flags, sfCompileTime) + else: + incl(sym.flags, sfCompileTime) #incl(sym.loc.flags, lfNoDecl) of wGlobal: noVal(c, it) diff --git a/tests/pragmas/t12558.nim b/tests/pragmas/t12558.nim new file mode 100644 index 0000000000..14fc74ceea --- /dev/null +++ b/tests/pragmas/t12558.nim @@ -0,0 +1,15 @@ +discard """ + nimout: '''@["1", "2", "3"]''' +""" + +import sequtils + +{.push compile_time.} + +proc foo = + echo map_it([1, 2, 3], $it) + +{.pop.} + +static: + foo()