summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-05-02 23:50:38 +0200
committerAraq <rumpf_a@web.de>2015-05-03 01:08:50 +0200
commit0f35a997dda9ad7579d0dade9dbe43d816145104 (patch)
treeee4956db726be00f531b85381a535dd5190fa954 /compiler
parent16a51ffc974672fdb883e92fa5fbb0e77d14c9ea (diff)
downloadNim-0f35a997dda9ad7579d0dade9dbe43d816145104.tar.gz
minor bugfixes to the new 'len(nil)==0' feature
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semfold.nim7
-rw-r--r--compiler/transf.nim3
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index f533c19b4..80b928383 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -286,10 +286,13 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode =
   of mNot: result = newIntNodeT(1 - getInt(a), n)
   of mCard: result = newIntNodeT(nimsets.cardSet(a), n)
   of mBitnotI, mBitnotI64: result = newIntNodeT(not getInt(a), n)
-  of mLengthStr, mXLenStr: result = newIntNodeT(len(getStr(a)), n)
+  of mLengthStr, mXLenStr:
+    if a.kind == nkNilLit: result = newIntNodeT(0, n)
+    else: result = newIntNodeT(len(getStr(a)), n)
   of mLengthArray: result = newIntNodeT(lengthOrd(a.typ), n)
   of mLengthSeq, mLengthOpenArray, mXLenSeq:
-    result = newIntNodeT(sonsLen(a), n) # BUGFIX
+    if a.kind == nkNilLit: result = newIntNodeT(0, n)
+    else: result = newIntNodeT(sonsLen(a), n) # BUGFIX
   of mUnaryPlusI, mUnaryPlusF64: result = a # throw `+` away
   of mToFloat, mToBiggestFloat:
     result = newFloatNodeT(toFloat(int(getInt(a))), n)
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 3bdbdfadd..57547b682 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -716,8 +716,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
     add(result, PTransNode(newSymNode(labl)))
   of nkBreakStmt: result = transformBreak(c, n)
   of nkWhileStmt: result = transformWhile(c, n)
-  of nkCall, nkHiddenCallConv, nkCommand, nkInfix, nkPrefix, nkPostfix,
-     nkCallStrLit:
+  of nkCallKinds:
     result = transformCall(c, n)
   of nkAddr, nkHiddenAddr:
     result = transformAddrDeref(c, n, nkDerefExpr, nkHiddenDeref)