mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 19:52:36 +00:00
@@ -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
16
tests/errmsgs/t6608.nim
Normal 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()
|
||||
Reference in New Issue
Block a user