tgcsafety.nim 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. cmd: "nim check $file"
  3. errormsg: "type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>"
  4. nimout: '''
  5. type mismatch: got <AsyncHttpServer, Port, proc (req: Request): Future[system.void]{.locks: <unknown>.}>
  6. but expected one of:
  7. proc serve(server: AsyncHttpServer; port: Port;
  8. callback: proc (request: Request): Future[void] {.closure, gcsafe.};
  9. address = ""): owned(Future[void])
  10. first type mismatch at position: 3
  11. required type for callback: proc (request: Request): Future[system.void]{.closure, gcsafe.}
  12. but expression 'cb' is of type: proc (req: Request): Future[system.void]{.locks: <unknown>.}
  13. This expression is not GC-safe. Annotate the proc with {.gcsafe.} to get extended error information.
  14. expression: serve(server, Port(7898), cb)
  15. '''
  16. """
  17. # bug #6186
  18. import asyncdispatch, asynchttpserver
  19. var server = newAsyncHttpServer()
  20. var foo = "foo"
  21. proc cb(req: Request) {.async.} =
  22. var baa = foo & "asds"
  23. await req.respond(Http200, baa)
  24. asyncCheck server.serve(Port(7898), cb )
  25. runForever()