diff options
Diffstat (limited to 'compiler/semfold.nim')
-rwxr-xr-x | compiler/semfold.nim | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim index d0805d921..e46bb0459 100755 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -587,16 +587,18 @@ proc getConstExpr(m: PSym, n: PNode): PNode = LocalError(a.info, errCannotEvalXBecauseIncompletelyDefined, "sizeof") result = nil - elif skipTypes(a.typ, abstractInst).kind in {tyArray,tyObject,tyTuple}: + elif skipTypes(a.typ, typedescInst).kind in + IntegralTypes+NilableTypes+{tySet}: + #{tyArray,tyObject,tyTuple}: + result = newIntNodeT(getSize(a.typ), n) + else: result = nil # XXX: size computation for complex types is still wrong - else: - result = newIntNodeT(getSize(a.typ), n) of mLow: result = newIntNodeT(firstOrd(n.sons[1].typ), n) of mHigh: if skipTypes(n.sons[1].typ, abstractVar).kind notin - {tyOpenArray, tyVarargs, tySequence, tyString}: + {tyOpenArray, tyVarargs, tySequence, tyString}: result = newIntNodeT(lastOrd(skipTypes(n[1].typ, abstractVar)), n) else: var a = getArrayConstr(m, n.sons[1]) |