fixes serious codegen regression that caused Nimble to misbehave

This commit is contained in:
Araq
2016-12-10 02:30:57 +01:00
parent 94e1488c24
commit 34143ee122
2 changed files with 48 additions and 1 deletions

View File

@@ -63,7 +63,7 @@ proc genTraverseProc(c: var TTraversalClosure, accessor: Rope, typ: PType) =
var p = c.p
case typ.kind
of tyGenericInst, tyGenericBody, tyTypeDesc, tyAlias:
of tyGenericInst, tyGenericBody, tyTypeDesc, tyAlias, tyDistinct:
genTraverseProc(c, accessor, lastSon(typ))
of tyArray:
let arraySize = lengthOrd(typ.sons[0])

View File

@@ -0,0 +1,47 @@
discard """
output: "done"
"""
type
Version* = distinct string
Special* = distinct string
VersionRangeEnum* = enum
verLater, # > V
verEarlier, # < V
verEqLater, # >= V -- Equal or later
verEqEarlier, # <= V -- Equal or earlier
verIntersect, # > V & < V
verEq, # V
verAny, # *
verSpecial # #head
VersionRange* = ref VersionRangeObj
VersionRangeObj = object
case kind*: VersionRangeEnum
of verLater, verEarlier, verEqLater, verEqEarlier, verEq:
ver*: Version
of verSpecial:
spe*: Special
of verIntersect:
verILeft, verIRight: VersionRange
of verAny:
nil
proc foo(x: string): VersionRange =
new(result)
result.kind = verEq
result.ver = Version(x)
proc main =
var a: array[5000, VersionRange]
for i in 0 ..< 5000:
a[i] = foo($i & "some longer text here " & $i)
GC_fullcollect()
for i in 0 ..< 5000:
let expected = $i & "some longer text here " & $i
if a[i].ver.string != expected:
quit "bug!"
echo "done"
main()