Skip to content

Instantly share code, notes, and snippets.

@mrwonko
mrwonko / errors.txt
Created March 19, 2018 21:27
Errors in a Nim snippet
in Visual Studio Code with https://play.nim-lang.org/?gist=e609c6c728d4cbf8751f0cf618d4df0e I got these errors:
type mismatch: got <int64> but expected 'bool'
type mismatch: got <Flags, set[range 0..65535(int)]>
but expected one of:
proc `==`(x, y: int32): bool
first type mismatch at position: 1
required type: int32
type
Boolable = concept x
if x: discard
Bool = concept x
x is bool
when isMainModule:
type MyInt = distinct int
converter toBool(x: MyInt): bool = int(x) != 0
doAssert(MyInt is Boolable)
import asynchttpserver, asyncdispatch
from strformat import `&`
let name = "Willi"
proc serveIndex(req: Request) {.async.} =
await req.respond(Http200, &"hello {name}")
let server = newAsyncHttpServer()
discard server.serve(Port(8080), serveIndex, address = "127.0.0.1")
import asynchttpserver, asyncdispatch
from strformat import `&`
proc main() =
let local = "123"
proc serveIndex(req: Request) {.async, gcsafe.} =
await req.respond(Http200, &"{local}")
proc serve404(req: Request) {.async, gcsafe.} =