fix #18886 crash on ambiguous proc cast (#20472)

* fix #18886 crash on ambiguous proc cast

* follow suggestion
This commit is contained in:
Bung 2022-10-10 17:09:54 +08:00 • committed by GitHub
commit db3d2971cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

18
tests/errmsgs/t18886.nim Normal file
View file

@ -0,0 +1,18 @@
discard """
cmd: "nim check --hints:off $file"
errormsg: ""
nimout: '''
t18886.nim(18, 24) Error: ambiguous identifier: 'bar' -- you need a helper proc to disambiguate the following:
t18886.bar: proc (i: ptr int){.noSideEffect, gcsafe, locks: 0.}
t18886.bar: proc (i: ptr char){.noSideEffect, gcsafe, locks: 0.}
'''
"""
type Foo = (proc(_: pointer): void)
proc bar(i: ptr[int]) = discard
proc bar(i: ptr[char]) = discard
let fooBar = cast[Foo](bar)