fixes #430
This commit is contained in:
parent
b3103c4657
commit
289c975d85
2 changed files with 24 additions and 6 deletions
|
|
@ -592,14 +592,20 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
else:
|
else:
|
||||||
result = typeRel(c, x, a) # check if it fits
|
result = typeRel(c, x, a) # check if it fits
|
||||||
of tyTypeDesc:
|
of tyTypeDesc:
|
||||||
if a.kind == tyTypeDesc:
|
var prev = PType(idTableGet(c.bindings, f))
|
||||||
if f.sonsLen == 0:
|
if prev == nil:
|
||||||
result = isGeneric
|
if a.kind == tyTypeDesc:
|
||||||
|
if f.sonsLen == 0:
|
||||||
|
result = isGeneric
|
||||||
|
else:
|
||||||
|
result = matchTypeClass(c, f, a.sons[0])
|
||||||
|
if result == isGeneric:
|
||||||
|
put(c.bindings, f, a)
|
||||||
else:
|
else:
|
||||||
result = matchTypeClass(c, f, a.sons[0])
|
result = isNone
|
||||||
if result == isGeneric: put(c.bindings, f, a)
|
|
||||||
else:
|
else:
|
||||||
result = isNone
|
InternalAssert prev.sonsLen == 1
|
||||||
|
result = typeRel(c, prev.sons[0], a)
|
||||||
of tyExpr, tyStmt:
|
of tyExpr, tyStmt:
|
||||||
result = isGeneric
|
result = isGeneric
|
||||||
of tyProxy:
|
of tyProxy:
|
||||||
|
|
|
||||||
12
tests/reject/tbindtypedesc.nim
Normal file
12
tests/reject/tbindtypedesc.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
discard """
|
||||||
|
line: 11
|
||||||
|
file: "tbindtypedesc.nim"
|
||||||
|
errormsg: "type mismatch: got (typedesc[float], string)"
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc foo(T: typedesc; some: T) =
|
||||||
|
echo($some)
|
||||||
|
|
||||||
|
foo int, 4
|
||||||
|
foo float, "bad"
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue