various bugfixes for generics; added generic sort proc

This commit is contained in:
Araq 2011-03-03 02:01:22 +01:00
commit e424e13bd9
18 changed files with 392 additions and 113 deletions

View file

@ -130,8 +130,11 @@ proc concreteType(mapping: TIdTable, t: PType): PType =
result = t
while true:
result = PType(idTableGet(mapping, t))
if result == nil: InternalError("lookup failed")
if result.kind != tyGenericParam: break
if result == nil:
break # it's ok, no match
# example code that triggers it:
# proc sort[T](cmp: proc(a, b: T): int = cmp)
if result.kind != tyGenericParam: break
else:
result = t # Note: empty is valid here