Skip to content

Commit

Permalink
use JsonNode.isNil rather than == nil to work around Nim issues (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec committed Jul 12, 2023
1 parent 325dd4e commit 3220034
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions json_rpc/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion json_rpc/jsonmarshal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3220034

Please sign in to comment.