From edbb32e4c49af8be06f35064e7873664100f1cfa Mon Sep 17 00:00:00 2001 From: Jake Leahy Date: Mon, 9 Mar 2026 21:59:12 +1100 Subject: [PATCH] Fix `getTypeImpl` not returning defaults (#25592) `getTypeImpl` and friends were always putting `nkEmpty` in the default value field which meant the default values couldn't be introspected. This copies the default AST so it can be seen in the returned object --- compiler/vmdeps.nim | 10 +++++-- tests/macros/tgettypeimpl_defaults.nim | 39 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 tests/macros/tgettypeimpl_defaults.nim diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 1ef6e33832..e15d27631a 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -62,7 +62,10 @@ proc objectNode(cache: IdentCache; n: PNode; idgen: IdGenerator): PNode = result = newNodeI(nkIdentDefs, n.info) result.add n # name result.add mapTypeToAstX(cache, n.sym.typ, n.info, idgen, true, false) # type - result.add newNodeI(nkEmpty, n.info) # no assigned value + if n.sym.ast != nil: + result.add copyTree(n.sym.ast) + else: + result.add newNodeI(nkEmpty, n.info) # no assigned value else: result = copyNode(n) for i in 0..