From 1abef2dc59e812f7aee41620bf5cd298f5cc8270 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 3 Sep 2018 12:27:23 +0200 Subject: [PATCH] improve the error message for 'addQuitProc' etc; fixes #5794 --- compiler/renderer.nim | 24 ++++++++++++------------ tests/errmsgs/tgcsafety.nim | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 8a25d76e8c..a8f3f4afc0 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -752,7 +752,8 @@ proc gproc(g: var TSrcGen, n: PNode) = gsub(g, n.sons[genericParamsPos]) g.inGenericParams = oldInGenericParams 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 n.sons[bodyPos].kind != nkEmpty: put(g, tkSpaces, Space) @@ -1297,17 +1298,16 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = putWithSpace(g, tkContinue, "continue") gsub(g, n, 0) of nkPragma: - if renderNoPragmas notin g.flags: - if g.inPragma <= 0: - inc g.inPragma - #if not previousNL(g): - put(g, tkSpaces, Space) - put(g, tkCurlyDotLe, "{.") - gcomma(g, n, emptyContext) - put(g, tkCurlyDotRi, ".}") - dec g.inPragma - else: - gcomma(g, n, emptyContext) + if g.inPragma <= 0: + inc g.inPragma + #if not previousNL(g): + put(g, tkSpaces, Space) + put(g, tkCurlyDotLe, "{.") + gcomma(g, n, emptyContext) + put(g, tkCurlyDotRi, ".}") + dec g.inPragma + else: + gcomma(g, n, emptyContext) of nkImportStmt, nkExportStmt: if n.kind == nkImportStmt: putWithSpace(g, tkImport, "import") diff --git a/tests/errmsgs/tgcsafety.nim b/tests/errmsgs/tgcsafety.nim index 4d192db904..ffc6905b07 100644 --- a/tests/errmsgs/tgcsafety.nim +++ b/tests/errmsgs/tgcsafety.nim @@ -5,7 +5,8 @@ nimout: ''' type mismatch: got .}> but expected one of: 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 required type: proc (request: Request): Future[system.void]{.closure, gcsafe.} but expression 'cb' is of type: proc (req: Request): Future[system.void]{.locks: .}