fix jsonutils macro with generic case object (#24429)

split from #24425

The added test did not work previously. The result of `getTypeImpl` is
the uninstantiated AST of the original type symbol, and the macro
attempts to use this type for the result. To fix the issue, the provided
`typedesc` argument is used instead.
This commit is contained in:
metagn
2024-11-12 16:31:08 +03:00
committed by GitHub
parent 76c5f16ac5
commit 45e21ce8f1
2 changed files with 14 additions and 1 deletions

View File

@@ -112,7 +112,7 @@ macro initCaseObject(T: typedesc, fun: untyped): untyped =
else: raiseAssert $t.kind # xxx `nnkPtrTy` could be handled too
doAssert t2.kind == nnkRecList
result = newTree(nnkObjConstr)
result.add sym
result.add T
for ti in t2:
if ti.kind == nnkRecCase:
let key = ti[0][0]