summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-12-28 13:26:41 +0200
committerZahary Karadjov <zahary@gmail.com>2013-12-28 14:17:36 +0200
commitf34ca1a7d7fe22c762b1a4bc29f4f1e19d5da0ec (patch)
tree7f11d1bb07ec24f5f1ff399e771336e422928c05 /compiler
parenta59f13b00dff570865201e860ea24d202b60c85a (diff)
downloadNim-f34ca1a7d7fe22c762b1a4bc29f4f1e19d5da0ec.tar.gz
fix illegal recursion checks
Diffstat (limited to 'compiler')
-rw-r--r--compiler/types.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/types.nim b/compiler/types.nim
index d47015836..a2869f0da 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -1144,8 +1144,10 @@ proc computeSizeAux(typ: PType, a: var biggestInt): biggestInt =
      tyBigNum: 
     result = ptrSize
     a = result
-  of tyArray, tyArrayConstr: 
-    result = lengthOrd(typ.sons[0]) * computeSizeAux(typ.sons[1], a)
+  of tyArray, tyArrayConstr:
+    let elemSize = computeSizeAux(typ.sons[1], a)
+    if elemSize < 0: return elemSize
+    result = lengthOrd(typ.sons[0]) * elemSize
   of tyEnum: 
     if firstOrd(typ) < 0: 
       result = 4              # use signed int32
@@ -1196,8 +1198,9 @@ proc computeSizeAux(typ: PType, a: var biggestInt): biggestInt =
   of tyGenericInst, tyDistinct, tyGenericBody, tyMutable, tyConst, tyIter:
     result = computeSizeAux(lastSon(typ), a)
   of tyTypeDesc:
-    result = (if typ.len == 1: computeSizeAux(typ.sons[0], a) else: -1)
-  of tyProxy: result = 1
+    result = if typ.len == 1: computeSizeAux(typ.sons[0], a)
+             else: szUnknownSize
+  of tyForward: return szIllegalRecursion
   else:
     #internalError("computeSizeAux()")
     result = szUnknownSize