parent
9ecb24e443
commit
95f8ed0382
2 changed files with 33 additions and 1 deletions
|
|
@ -124,6 +124,12 @@ proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PType) =
|
||||||
initIdTable(c.bindings)
|
initIdTable(c.bindings)
|
||||||
|
|
||||||
proc put(c: var TCandidate, key, val: PType) {.inline.} =
|
proc put(c: var TCandidate, key, val: PType) {.inline.} =
|
||||||
|
when false:
|
||||||
|
let old = PType(idTableGet(c.bindings, key))
|
||||||
|
if old != nil:
|
||||||
|
echo "Putting ", typeToString(key), " ", typeToString(val), " and old is ", typeToString(old)
|
||||||
|
if typeToString(old) == "seq[string]":
|
||||||
|
writeStackTrace()
|
||||||
idTablePut(c.bindings, key, val.skipIntLit)
|
idTablePut(c.bindings, key, val.skipIntLit)
|
||||||
|
|
||||||
proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PSym,
|
proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PSym,
|
||||||
|
|
@ -1520,7 +1526,12 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||||
elif x.kind in {tyGenericInvocation, tyGenericParam}:
|
elif x.kind in {tyGenericInvocation, tyGenericParam}:
|
||||||
internalError(c.c.graph.config, "wrong instantiated type!")
|
internalError(c.c.graph.config, "wrong instantiated type!")
|
||||||
else:
|
else:
|
||||||
put(c, f.sons[i], x)
|
let key = f.sons[i]
|
||||||
|
let old = PType(idTableGet(c.bindings, key))
|
||||||
|
if old == nil:
|
||||||
|
put(c, key, x)
|
||||||
|
elif typeRel(c, old, x, flags + {trDontBind}) == isNone:
|
||||||
|
return isNone
|
||||||
|
|
||||||
if result == isNone:
|
if result == isNone:
|
||||||
# Here object inheriting from generic/specialized generic object
|
# Here object inheriting from generic/specialized generic object
|
||||||
|
|
|
||||||
21
tests/generics/tprevent_double_bind.nim
Normal file
21
tests/generics/tprevent_double_bind.nim
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "type mismatch: got <TT[seq[string]], proc (v: int){.gcsafe, locks: 0.}>"
|
||||||
|
line: 20
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #6732
|
||||||
|
import typetraits
|
||||||
|
|
||||||
|
type
|
||||||
|
TT[T] = ref object of RootObj
|
||||||
|
val: T
|
||||||
|
CB[T] = proc (v: T)
|
||||||
|
|
||||||
|
proc testGeneric[T](val: TT[T], cb: CB[T]) =
|
||||||
|
echo val.type.name
|
||||||
|
echo $val.val
|
||||||
|
|
||||||
|
var tt = new(TT[seq[string]])
|
||||||
|
echo tt.type.name
|
||||||
|
tt.testGeneric( proc (v: int) =
|
||||||
|
echo $v )
|
||||||
Loading…
Add table
Add a link
Reference in a new issue