fix tbindtypedesc and tactiontable2

This commit is contained in:
Zahary Karadjov 2014-02-18 01:37:00 +02:00
commit 4d3846e26b
2 changed files with 13 additions and 6 deletions

View file

@ -900,20 +900,27 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
result = isNone result = isNone
of tyTypeDesc: of tyTypeDesc:
if a.kind != tyTypeDesc: return isNone
var prev = PType(idTableGet(c.bindings, f)) var prev = PType(idTableGet(c.bindings, f))
if prev == nil: if prev == nil:
# proc foo(T: typedesc, x: T)
# when `f` is an unresolved typedesc, `a` could be any
# type, so we should not perform this check earlier
if a.kind != tyTypeDesc: return isNone
if f.base.kind == tyNone: if f.base.kind == tyNone:
result = isGeneric result = isGeneric
else: else:
result = typeRel(c, f.base, a.base) result = typeRel(c, f.base, a.base)
if result != isNone: if result != isNone:
put(c.bindings, f, a) put(c.bindings, f, a)
else: else:
let toMatch = if tfUnresolved in f.flags: a if tfUnresolved in f.flags:
else: a.base result = typeRel(c, prev.base, a)
result = typeRel(c, prev.base, toMatch) elif a.kind == tyTypeDesc:
result = typeRel(c, prev.base, a.base)
else:
result = isNone
of tyStmt: of tyStmt:
result = isGeneric result = isGeneric

View file

@ -1,6 +1,6 @@
discard """ discard """
line: 21 line: 21
errormsg: "invalid type: 'TTable'" errormsg: "invalid type: 'TTable[string, proc (string)]'"
""" """
import tables import tables