fix tbindtypedesc and tactiontable2
This commit is contained in:
parent
765c682c92
commit
4d3846e26b
2 changed files with 13 additions and 6 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue