This commit is contained in:
Andreas Rumpf 2018-02-11 14:52:19 +01:00
commit a4deceb134
2 changed files with 46 additions and 2 deletions

View file

@ -0,0 +1,30 @@
discard """
cmd: "nim check $file"
errormsg: "type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>"
nimout: '''
type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
but expected one of:
proc serve(server: AsyncHttpServer; port: Port;
callback: proc (request: Request): Future[void]; 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: <unknown>.}
This expression is not GC-safe. Annotate the proc with {.gcsafe.} to get extended error information.
expression: serve(server, Port(7898), cb)
'''
"""
# bug #6186
import asyncdispatch, asynchttpserver
var server = newAsyncHttpServer()
var foo = "foo"
proc cb(req: Request) {.async.} =
var baa = foo & "asds"
await req.respond(Http200, baa)
asyncCheck server.serve(Port(7898), cb )
runForever()