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

fix #15836 proc arg return type auto unexpectly match proc with concrete type
This commit is contained in:
Bung 2022-12-10 01:01:13 +08:00 • committed by GitHub
commit 0cd9bdcf9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 23 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