use JsonNode.isNil rather than == nil to work around Nim issues (#167)

This commit is contained in:
tersec 2023-07-12 17:34:34 +00:00 committed by GitHub
parent 325dd4ec35
commit 32200345f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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`

View File

@ -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)