diff options
author | Araq <rumpf_a@web.de> | 2014-11-27 08:36:58 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-11-27 08:36:58 +0100 |
commit | 7edf6fc1d2f8feb8d126065f5429afa71e4aa06e (patch) | |
tree | 490d95168c112cbf1f5db51ddecb9544de410d5e /compiler | |
parent | c1930f1b6e8dd8e542e9982a3791ead864875fff (diff) | |
download | Nim-7edf6fc1d2f8feb8d126065f5429afa71e4aa06e.tar.gz |
fixes #1547
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | compiler/trees.nim | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index e05828f8f..547d0d376 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 b1edd21f3..86a1139a0 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 .. <n.len: if not isDeepConstExpr(n.sons[i]): return false - result = true + # XXX once constant objects are supported by the codegen this needs to be + # weakened: + result = n.typ.isNil or n.typ.skipTypes({tyGenericInst, tyDistinct}).kind != tyObject else: discard proc flattenTreeAux(d, a: PNode, op: TMagic) = |