fix illegal recursion checks

This commit is contained in:
Zahary Karadjov 2013-12-28 13:26:41 +02:00
commit f34ca1a7d7
3 changed files with 18 additions and 18 deletions

View file

@ -1145,7 +1145,9 @@ proc computeSizeAux(typ: PType, a: var biggestInt): biggestInt =
result = ptrSize
a = result
of tyArray, tyArrayConstr:
result = lengthOrd(typ.sons[0]) * computeSizeAux(typ.sons[1], a)
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

View file

@ -14,4 +14,3 @@ type
y: Int
x: array[0..3, TIllegal]

View file

@ -6,5 +6,3 @@ discard """
type
Uint8 = Uint8 #ERROR_MSG illegal recursion in type 'Uint8'