mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 23:05:27 +00:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user