From c786415eef75fda3fb957f67edb53943c2d88fea Mon Sep 17 00:00:00 2001 From: SirOlaf <34164198+SirOlaf@users.noreply.github.com> Date: Wed, 17 Jul 2024 23:54:15 +0200 Subject: [PATCH] Set type of object constructor during annotateType (#23852) Fix https://github.com/nim-lang/Nim/issues/23547 Tested locally with the included test, the test from constantine and the original issue. (cherry picked from commit f765898a7518f5c6bbebffd4217ccc35fd02747d) --- compiler/semmacrosanity.nim | 1 + tests/macros/t23547.nim | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/macros/t23547.nim diff --git a/compiler/semmacrosanity.nim b/compiler/semmacrosanity.nim index 12d7d32e0b..f95539c9a2 100644 --- a/compiler/semmacrosanity.nim +++ b/compiler/semmacrosanity.nim @@ -51,6 +51,7 @@ proc annotateType*(n: PNode, t: PType; conf: ConfigRef) = of nkObjConstr: let x = t.skipTypes(abstractPtrs) n.typ = t + n[0].typ = t for i in 1..