From 693b35b59f5b77ab4bb0dba0815bd30e307ce0e2 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 f2845aa198..4dc69a647d 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -228,6 +228,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..