From e2f1fab458efe8997d96ae2b8fbf1ebb0d886de0 Mon Sep 17 00:00:00 2001 From: cooldome Date: Tue, 24 Nov 2020 14:49:14 +0000 Subject: [PATCH] fix #16110 (#16117) (cherry picked from commit 1d14b2c9e61c5e9389f8b52839814156dcf259dd) --- compiler/semstmts.nim | 3 ++- tests/macros/tgetimpl.nim | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index aa882770a5..d7f83397ee 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1277,7 +1277,8 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = incl st.flags, tfRefsAnonObj let obj = newSym(skType, getIdent(c.cache, s.name.s & ":ObjectType"), getCurrOwner(c), s.info) - obj.ast = a + obj.ast = a.copyTree + obj.ast[0] = newSymNode(obj) if sfPure in s.flags: obj.flags.incl sfPure obj.typ = st.lastSon diff --git a/tests/macros/tgetimpl.nim b/tests/macros/tgetimpl.nim index d231a4336a..de655561b8 100644 --- a/tests/macros/tgetimpl.nim +++ b/tests/macros/tgetimpl.nim @@ -65,3 +65,21 @@ macro check_gen_proc(ex: typed): (bool, bool) = let a = @[1,2,3] assert: check_gen_proc(len(a)) == (false, true) + +#--------------------------------------------------------------- +# issue #16110 + +macro check(x: type): untyped = + let z = getType(x) + let y = getImpl(z[1]) + echo z.treeRepr + expectKind(z[1], nnkSym) + expectKind(y[0], nnkSym) + doAssert(y[0] == z[1]) + +type + TirePtr = ptr object + code: int + +var z: TirePtr +check(typeof(z[])) \ No newline at end of file