summary refs log tree commit diff stats
path: root/tests/errmsgs/tgcsafety.nim
blob: 0ae60f200d8497a7afb62e177f159f92cb624e9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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] {.closure, gcsafe.};
          address = ""): owned(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()