* fix #6608
This commit is contained in:
flywind
2020-07-14 15:22:48 +08:00
committed by GitHub
parent f4f21c89e5
commit 086efac49b
2 changed files with 26 additions and 1 deletions

View File

@@ -955,8 +955,17 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
hasErrorType = true
break
if not hasErrorType:
let typ = n[0].typ
msg.add(">\nbut expected one of: \n" &
typeToString(n[0].typ))
typeToString(typ))
# prefer notin preferToResolveSymbols
# t.sym != nil
# sfAnon notin t.sym.flags
# t.kind != tySequence(It is tyProc)
if typ.sym != nil and sfAnon notin typ.sym.flags and
typ.kind == tyProc:
msg.add(" = " &
typeToString(typ, preferDesc))
localError(c.config, n.info, msg)
return errorNode(c, n)
result = nil

16
tests/errmsgs/t6608.nim Normal file
View File

@@ -0,0 +1,16 @@
discard """
cmd: "nim c --hints:off $file"
errormsg: "type mismatch: got <>"
nimout: '''t6608.nim(14, 4) Error: type mismatch: got <>
but expected one of:
AcceptCB = proc (s: string){.closure.}'''
line: 14
"""
type
AcceptCB = proc (s: string)
proc x(x: AcceptCB) =
x()
x()