Skip to content

Commit

Permalink
Fix optional parameter parsing fails in rpc macro with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jan 4, 2024
1 parent f59e387 commit 014658d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions json_rpc/private/server_handler_wrapper.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ iterator paramsRevIter(params: NimNode): tuple[name, ntype: NimNode] =
yield (arg[j], argType)

proc isOptionalArg(typeNode: NimNode): bool =
typeNode.kind == nnkBracketExpr and
# typed version
(typeNode.kind == nnkCall and
typeNode.len > 1 and
typeNode[1].kind in {nnkIdent, nnkSym} and
typeNode[1].strVal == "Option") or

# untyped version
(typeNode.kind == nnkBracketExpr and
typeNode[0].kind == nnkIdent and
typeNode[0].strVal == "Option"
typeNode[0].strVal == "Option")

proc expectOptionalArrayLen(node: NimNode,
parameters: NimNode,
Expand Down

0 comments on commit 014658d

Please sign in to comment.