fix #15836 proc arg return type auto unexpectly match proc with concr… (#21065)

* fix #15836 proc arg return type auto unexpectly match proc with concrete type

* fix #16244

* add test case for #12869
This commit is contained in:
Bung 2022-12-12 13:26:18 +08:00 • committed by GitHub
commit 5917c2d5b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 74 additions and 12 deletions

11
tests/types/t15836.nim Normal file
View file

@ -0,0 +1,11 @@
discard """
errormsg: "type mismatch: got <string> but expected 'int'"
line: 11
"""
proc takesProc[T](x: T, f: proc(x: T): int) =
echo f(x) + 2
takesProc(1, proc (a: int): int = 2) # ok, prints 4
takesProc(1, proc (a: auto): auto = 2) # ok, prints 4
takesProc(1, proc (a: auto): auto = "uh uh") # prints garbage