summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-07-15 01:55:42 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-07-15 01:55:42 +0200
commitab3c684c62c3a10d08ce8941d2296c55b1386c18 (patch)
tree3f1fa8f5b42a11da35eacd23bc3a1136e922aa92
parentdb56174a19c8bd35430324ddd7f4be6ca3295bd3 (diff)
downloadNim-ab3c684c62c3a10d08ce8941d2296c55b1386c18.tar.gz
fixes #3545
-rw-r--r--compiler/semfold.nim13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index 26d309cfd..8e57ed0e2 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -286,13 +286,14 @@ 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: result = newIntNodeT(not getInt(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:
-    if a.kind == nkNilLit: result = newIntNodeT(0, n)
-    else: result = newIntNodeT(sonsLen(a), n) # BUGFIX
+  of mLengthSeq, mLengthOpenArray, mXLenSeq, mLengthStr, mXLenStr:
+    if a.kind == nkNilLit:
+      result = newIntNodeT(0, n)
+    elif a.kind in {nkStrLit..nkTripleStrLit}:
+      result = newIntNodeT(len a.strVal, 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)