Calling an async proc with invalid arguments will now fail at compile-time.
This commit is contained in:
parent
d15e67e020
commit
a1a8925692
3 changed files with 52 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import sockets, asyncio, strutils
|
||||
|
||||
proc processRequest(client: PAsyncSocket, test: string) {.async.} =
|
||||
assert test == "ahha"
|
||||
assert client != nil
|
||||
|
|
|
|||
32
tests/reject/tasyncmacroinvalidargs.nim
Normal file
32
tests/reject/tasyncmacroinvalidargs.nim
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
discard """
|
||||
msg: "type mismatch: got (int literal(234)) but expected 'string'"
|
||||
"""
|
||||
import sockets, asyncio, strutils
|
||||
|
||||
proc processRequest(client: PAsyncSocket, test: string) {.async.} =
|
||||
assert test == "ahha"
|
||||
assert client != nil
|
||||
echo("Test = ", test)
|
||||
let line = await(readLine(client))
|
||||
echo("Read: ", line)
|
||||
|
||||
await send(client, "Goodbye.\c\L")
|
||||
client.close()
|
||||
|
||||
proc processServer() {.async.} =
|
||||
var sock = AsyncSocket()
|
||||
|
||||
# blocks:
|
||||
sock.bindAddr(TPort(6667))
|
||||
sock.listen()
|
||||
|
||||
# Accept loop
|
||||
while true:
|
||||
let client: PAsyncSocket = await(accept(sock))
|
||||
assert client != nil
|
||||
await processRequest(client, 234)
|
||||
|
||||
var disp = newDispatcher(false)
|
||||
disp.register(processServer, nil)
|
||||
while true:
|
||||
discard disp.poll()
|
||||
Loading…
Add table
Add a link
Reference in a new issue