Skip to content

Commit

Permalink
fix nim-lang#19700 Crash when passing a template to a generic functio… (
Browse files Browse the repository at this point in the history
nim-lang#20567)

fix nim-lang#19700 Crash when passing a template to a generic function expecting a procedure
  • Loading branch information
bung87 authored and capocasa committed Mar 31, 2023
1 parent 4a00f47 commit 0056ec2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/template/t19700.nim
Original file line number Diff line number Diff line change
@@ -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, `!=`)

0 comments on commit 0056ec2

Please sign in to comment.