@@ -1474,11 +1474,17 @@ proc getOwner(c: PCtx): PSym =
1474
1474
result = c.prc.sym
1475
1475
if result .isNil: result = c.module
1476
1476
1477
+ proc importcCondVar* (s: PSym): bool {.inline.} =
1478
+ # see also importcCond
1479
+ if sfImportc in s.flags:
1480
+ return s.kind in {skVar, skLet, skConst}
1481
+
1477
1482
proc checkCanEval(c: PCtx; n: PNode) =
1478
1483
# we need to ensure that we don't evaluate 'x' here:
1479
1484
# proc foo() = var x ...
1480
1485
let s = n.sym
1481
1486
if {sfCompileTime, sfGlobal} <= s.flags: return
1487
+ if s.importcCondVar: return
1482
1488
if s.kind in {skVar, skTemp, skLet, skParam, skResult} and
1483
1489
not s.isOwnedBy(c.prc.sym) and s.owner != c.module and c.mode != emRepl:
1484
1490
# little hack ahead for bug #12612: assume gensym'ed variables
@@ -1618,12 +1624,12 @@ proc genRdVar(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
1618
1624
assert card(flags * {gfNodeAddr, gfNode}) < 2
1619
1625
let s = n.sym
1620
1626
if s.isGlobal:
1621
- if sfCompileTime in s.flags or c.mode == emRepl:
1627
+ if sfCompileTime in s.flags or c.mode == emRepl or importcCondVar(s) :
1622
1628
discard
1623
1629
elif s.position == 0 :
1624
1630
cannotEval(c, n)
1625
1631
if s.position == 0 :
1626
- if importcCond(s): c.importcSym(n.info, s)
1632
+ if importcCond(s) or importcCondVar(s) : c.importcSym(n.info, s)
1627
1633
else : genGlobalInit(c, n, s)
1628
1634
if dest < 0 : dest = c.getTemp(n.typ)
1629
1635
assert s.typ != nil
0 commit comments