diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index e05828f8f6..547d0d376a 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1718,7 +1718,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) = proc genConstExpr(p: BProc, n: PNode): PRope proc handleConstExpr(p: BProc, n: PNode, d: var TLoc): bool = - if (nfAllConst in n.flags) and (d.k == locNone) and (sonsLen(n) > 0): + if nfAllConst in n.flags and d.k == locNone and n.len > 0 and n.isDeepConstExpr: var t = getUniqueType(n.typ) discard getTypeDesc(p.module, t) # so that any fields are initialized var id = nodeTableTestOrSet(p.module.dataCache, n, gBackendId) diff --git a/compiler/trees.nim b/compiler/trees.nim index b1edd21f3b..86a1139a0f 100644 --- a/compiler/trees.nim +++ b/compiler/trees.nim @@ -117,7 +117,9 @@ proc isDeepConstExpr*(n: PNode): bool = of nkCurly, nkBracket, nkPar, nkObjConstr, nkClosure: for i in 0 ..