improve the error message for 'addQuitProc' etc; fixes #5794

This commit is contained in:
Araq 2018-09-03 12:27:23 +02:00
commit 1abef2dc59
2 changed files with 14 additions and 13 deletions

View file

@ -752,7 +752,8 @@ proc gproc(g: var TSrcGen, n: PNode) =
gsub(g, n.sons[genericParamsPos]) gsub(g, n.sons[genericParamsPos])
g.inGenericParams = oldInGenericParams g.inGenericParams = oldInGenericParams
gsub(g, n.sons[paramsPos]) gsub(g, n.sons[paramsPos])
gsub(g, n.sons[pragmasPos]) if renderNoPragmas notin g.flags:
gsub(g, n.sons[pragmasPos])
if renderNoBody notin g.flags: if renderNoBody notin g.flags:
if n.sons[bodyPos].kind != nkEmpty: if n.sons[bodyPos].kind != nkEmpty:
put(g, tkSpaces, Space) put(g, tkSpaces, Space)
@ -1297,17 +1298,16 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
putWithSpace(g, tkContinue, "continue") putWithSpace(g, tkContinue, "continue")
gsub(g, n, 0) gsub(g, n, 0)
of nkPragma: of nkPragma:
if renderNoPragmas notin g.flags: if g.inPragma <= 0:
if g.inPragma <= 0: inc g.inPragma
inc g.inPragma #if not previousNL(g):
#if not previousNL(g): put(g, tkSpaces, Space)
put(g, tkSpaces, Space) put(g, tkCurlyDotLe, "{.")
put(g, tkCurlyDotLe, "{.") gcomma(g, n, emptyContext)
gcomma(g, n, emptyContext) put(g, tkCurlyDotRi, ".}")
put(g, tkCurlyDotRi, ".}") dec g.inPragma
dec g.inPragma else:
else: gcomma(g, n, emptyContext)
gcomma(g, n, emptyContext)
of nkImportStmt, nkExportStmt: of nkImportStmt, nkExportStmt:
if n.kind == nkImportStmt: if n.kind == nkImportStmt:
putWithSpace(g, tkImport, "import") putWithSpace(g, tkImport, "import")

View file

@ -5,7 +5,8 @@ nimout: '''
type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}> type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
but expected one of: but expected one of:
proc serve(server: AsyncHttpServer; port: Port; proc serve(server: AsyncHttpServer; port: Port;
callback: proc (request: Request): Future[void]; address = ""): Future[void] callback: proc (request: Request): Future[void] {.closure, gcsafe.};
address = ""): Future[void]
first type mismatch at position: 3 first type mismatch at position: 3
required type: proc (request: Request): Future[system.void]{.closure, gcsafe.} required type: proc (request: Request): Future[system.void]{.closure, gcsafe.}
but expression 'cb' is of type: proc (req: Request): Future[system.void]{.locks: <unknown>.} but expression 'cb' is of type: proc (req: Request): Future[system.void]{.locks: <unknown>.}