fix nim-lang#19700 Crash when passing a template to a generic function expecting a procedure
This commit is contained in:
parent
57574eaf31
commit
0510a2be0d
2 changed files with 12 additions and 0 deletions
|
|
@ -2131,6 +2131,8 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
|
||||||
result = c.semInferredLambda(c, m.bindings, arg)
|
result = c.semInferredLambda(c, m.bindings, arg)
|
||||||
elif arg.kind != nkSym:
|
elif arg.kind != nkSym:
|
||||||
return nil
|
return nil
|
||||||
|
elif arg.sym.kind in {skMacro, skTemplate}:
|
||||||
|
return nil
|
||||||
else:
|
else:
|
||||||
let inferred = c.semGenerateInstance(c, arg.sym, m.bindings, arg.info)
|
let inferred = c.semGenerateInstance(c, arg.sym, m.bindings, arg.info)
|
||||||
result = newSymNode(inferred, arg.info)
|
result = newSymNode(inferred, arg.info)
|
||||||
|
|
|
||||||
10
tests/template/t19700.nim
Normal file
10
tests/template/t19700.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "type mismatch: got <Obj, Obj, template (x: untyped, y: untyped): untyped>"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type Obj = object
|
||||||
|
|
||||||
|
proc apply[T, R](a, b: T; f: proc(x, y: T): R): R = f(a, b)
|
||||||
|
|
||||||
|
let a, b = Obj()
|
||||||
|
discard apply(a, b, `!=`)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue