tgcsafety.nim 1.1 KB

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