Fix optional parameter parsing fails in rpc macro with generics

This commit is contained in:
jangko 2024-01-04 11:17:31 +07:00
parent f59e387da2
commit 014658d1e4
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9

View File

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