From ca1c516295e1711daf94e31f76d767efc27dc7a0 Mon Sep 17 00:00:00 2001 From: Clay Sweetser Date: Sat, 7 Jun 2014 23:29:53 -0400 Subject: Fixing issue #1090 --- compiler/semstmts.nim | 3 +++ compiler/types.nim | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index d17351988..11399b38b 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -828,6 +828,9 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = getCurrOwner(), s.info) proc semTypeSection(c: PContext, n: PNode): PNode = + ## Processes a type section. This must be done in separate passes, in order + ## to allow the type definitions in the section to reference each other + ## without regard for the order of their definitions. typeSectionLeftSidePass(c, n) typeSectionRightSidePass(c, n) typeSectionFinalPass(c, n) diff --git a/compiler/types.nim b/compiler/types.nim index 1f266d64f..b2e131f60 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1152,11 +1152,12 @@ proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt = result = computeSizeAux(n.sym.typ, a) n.sym.offset = int(currOffset) else: - internalError("computeRecSizeAux()") + # internalError("computeRecSizeAux()") + n.debug a = 1 - result = - 1 + result = - 2 -const +const szIllegalRecursion* = -2 szUnknownSize* = -1 -- cgit 1.4.1-2-gfad0 From 912ad820ee1127a595207d2067f0b6eeb0902dca Mon Sep 17 00:00:00 2001 From: Clay Sweetser Date: Sun, 15 Jun 2014 20:01:48 -0400 Subject: Fixed #1090 --- compiler/types.nim | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/compiler/types.nim b/compiler/types.nim index b2e131f60..786eea14e 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1118,6 +1118,11 @@ proc typeAllowed(t: PType, kind: TSymKind): bool = proc align(address, alignment: BiggestInt): BiggestInt = result = (address + (alignment - 1)) and not (alignment - 1) +const + szNonConcreteType* = -3 + szIllegalRecursion* = -2 + szUnknownSize* = -1 + proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt = var maxAlign, maxSize, b, res: BiggestInt @@ -1151,15 +1156,9 @@ proc computeRecSizeAux(n: PNode, a, currOffset: var BiggestInt): BiggestInt = of nkSym: result = computeSizeAux(n.sym.typ, a) n.sym.offset = int(currOffset) - else: - # internalError("computeRecSizeAux()") - n.debug + else: a = 1 - result = - 2 - -const - szIllegalRecursion* = -2 - szUnknownSize* = -1 + result = szNonConcreteType proc computeSizeAux(typ: PType, a: var BiggestInt): BiggestInt = var res, maxAlign, length, currOffset: BiggestInt -- cgit 1.4.1-2-gfad0