fix #2614 improve error message when array of proc calling convention… (#20379)

fix #2614 improve error message when array of proc calling convention mismatch
This commit is contained in:
Bung 2022-09-26 17:58:13 +08:00 • committed by GitHub
commit e13cd40e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 31 deletions

21
tests/errmsgs/t2614.nim Normal file
View file

@ -0,0 +1,21 @@
discard """
cmd: "nim check $options --hints:off $file"
errormsg: ""
nimout: '''
t2614.nim(19, 27) Error: type mismatch: got <array[0..1, proc (){.locks: <unknown>.}]> but expected 'array[0..1, proc (){.closure.}]'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
t2614.nim(21, 22) Error: type mismatch: got <seq[proc (){.locks: <unknown>.}]> but expected 'seq[proc (){.closure.}]'
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
'''
"""
proc g
proc f =
if false: g()
proc g =
if false: f()
var a = [f, g] # This works
var b: array[2, proc()] = [f, g] # Error
var c: seq[proc()] = @[f, g]