fix #15836 proc arg return type auto unexpectly match proc with concrete type
This commit is contained in:
parent
ef190f349d
commit
0cd9bdcf9f
9 changed files with 23 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
discard """
|
||||
cmd: "nim check $file"
|
||||
cmd: "nim check --hints:off $file"
|
||||
errormsg: ""
|
||||
nimout: '''
|
||||
tillegalreturntype.nim(11, 11) Error: return type 'typed' is only valid for macros and templates
|
||||
|
|
|
|||
11
tests/types/t15836.nim
Normal file
11
tests/types/t15836.nim
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue