mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-08 00:23:12 +00:00
use JsonNode.isNil rather than == nil to work around Nim issues (#167)
This commit is contained in:
parent
325dd4ec35
commit
32200345f8
@ -38,7 +38,7 @@ method close*(client: RpcClient): Future[void] {.
|
||||
discard
|
||||
|
||||
template `or`(a: JsonNode, b: typed): JsonNode =
|
||||
if a == nil: b else: a
|
||||
if a.isNil: b else: a
|
||||
|
||||
proc processMessage*(self: RpcClient, line: string) =
|
||||
# Note: this doesn't use any transport code so doesn't need to be
|
||||
@ -163,7 +163,7 @@ proc createRpcFromSig*(clientType, rpcDecl: NimNode): NimNode =
|
||||
else:
|
||||
# native json expected so no work
|
||||
callBody.add quote do:
|
||||
`procRes` = if `rpcResult` == nil:
|
||||
`procRes` = if `rpcResult`.isNil:
|
||||
newJNull()
|
||||
else:
|
||||
`rpcResult`
|
||||
|
||||
@ -148,7 +148,7 @@ proc fromJson*[N, T](n: JsonNode, argName: string, result: var array[N, T]) =
|
||||
|
||||
proc unpackArg[T](args: JsonNode, argName: string, argtype: typedesc[T]): T =
|
||||
mixin fromJson
|
||||
if args == nil:
|
||||
if args.isNil:
|
||||
raise (ref ValueError)(msg: argName & ": unexpected null value")
|
||||
{.gcsafe.}:
|
||||
fromJson(args, argName, result)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user