From babc7d8c16be56a99b5d3e28bbd02edc0576beaa Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:08:35 +0800 Subject: [PATCH] fixes #23545; C compiler error when default initializing an object field function (#24375) fixes #23545 (cherry picked from commit 815bbf0e7312b62de6a8df96349329dbb1740fb9) --- compiler/semtypes.nim | 17 +++++++++++++++++ tests/objects/tobject_default_value.nim | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index e3c6fb1090..757076f850 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -257,6 +257,22 @@ proc isRecursiveType(t: PType, cycleDetector: var IntSet): bool = else: return false +proc annotateClosureConv(n: PNode) = + case n.kind + of {nkNone..nkNilLit}: + discard + of nkTupleConstr: + if n.typ.kind == tyProc and n.typ.callConv == ccClosure and + n[0].typ.kind == tyProc and n[0].typ.callConv != ccClosure: + # restores `transf.generateThunk` + n[0] = newTreeIT(nkHiddenSubConv, n[0].info, n.typ, + newNodeI(nkEmpty, n[0].info), n[0]) + n.transitionSonsKind(nkClosure) + n.flags.incl nfTransf + else: + for i in 0..