mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-06 07:38:24 +00:00
fix nim-lang#19700 Crash when passing a template to a generic function expecting a procedure
This commit is contained in:
@@ -2131,6 +2131,8 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
|
||||
result = c.semInferredLambda(c, m.bindings, arg)
|
||||
elif arg.kind != nkSym:
|
||||
return nil
|
||||
elif arg.sym.kind in {skMacro, skTemplate}:
|
||||
return nil
|
||||
else:
|
||||
let inferred = c.semGenerateInstance(c, arg.sym, m.bindings, 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, `!=`)
|
||||
Reference in New Issue
Block a user