more fixes for new integer promotion rules; fixes #152; fixes #157; fixes #156; fixes #155

This commit is contained in:
Araq 2012-07-09 21:11:11 +02:00
commit 4966212141
8 changed files with 27 additions and 20 deletions

View file

@ -391,6 +391,7 @@ proc symToYaml(n: PSym, indent: int = 0, maxRecDepth: int = - 1): PRope =
var marker = InitIntSet()
result = symToYamlAux(n, marker, indent, maxRecDepth)
proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope
proc debugType(n: PType): PRope =
if n == nil:
result = toRope("null")
@ -407,6 +408,9 @@ proc debugType(n: PType): PRope =
app(result, "null")
else:
app(result, debugType(n.sons[i]))
if n.kind == tyObject and n.n != nil:
app(result, ", node: ")
app(result, debugTree(n.n, 2, 100))
app(result, ")")
proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope =

View file

@ -601,7 +601,10 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
else:
result = magicCall(m, n)
of mIs:
result = newIntNodeT(ord(sameType(n[1].typ, n[2].typ)), n)
# BUGFIX: don't evaluate this too early: ``T is void``
if not containsGenericType(n[1].typ) and
not containsGenericType(n[2].typ):
result = newIntNodeT(ord(sameType(n[1].typ, n[2].typ)), n)
of mAstToStr:
result = newStrNodeT(renderTree(n[1], {renderNoComments}), n)
of mConStrStr:

View file

@ -30,12 +30,6 @@ proc checkConstructedType*(info: TLineInfo, typ: PType) =
if t.kind == tyObject and t.sons[0] != nil:
if t.sons[0].kind != tyObject or tfFinal in t.sons[0].flags:
localError(info, errInheritanceOnlyWithNonFinalObjects)
proc containsGenericTypeIter(t: PType, closure: PObject): bool =
result = t.kind in GenericTypes
proc containsGenericType*(t: PType): bool =
result = iterOverType(t, containsGenericTypeIter, nil)
proc searchInstTypes(tab: TIdTable, key: PType): PType =
# returns nil if we need to declare this type

View file

@ -1094,3 +1094,9 @@ proc getSize(typ: PType): biggestInt =
result = computeSize(typ)
if result < 0: InternalError("getSize(" & $typ.kind & ')')
proc containsGenericTypeIter(t: PType, closure: PObject): bool =
result = t.kind in GenericTypes
proc containsGenericType*(t: PType): bool =
result = iterOverType(t, containsGenericTypeIter, nil)