From c71ae94d3af09a0bdedc456d51b522fe6679b41f Mon Sep 17 00:00:00 2001 From: metagn Date: Tue, 15 Oct 2024 11:46:19 +0300 Subject: [PATCH] still need wrapper --- compiler/cbuilderdecls.nim | 2 +- compiler/ccgexprs.nim | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/cbuilderdecls.nim b/compiler/cbuilderdecls.nim index 74ed391431ec..e5032d743116 100644 --- a/compiler/cbuilderdecls.nim +++ b/compiler/cbuilderdecls.nim @@ -68,7 +68,7 @@ type siOrderedStruct ## struct constructor, but without named fields on C siNamedStruct ## struct constructor, with named fields i.e. C99 designated initializer siArray ## array constructor - siWrapper ## wrapper for a single field, generates it verbatim, now unused + siWrapper ## wrapper for a single field, generates it verbatim StructInitializer = object ## context for building struct initializers, i.e. `{ field1, field2 }` diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 42b953fd7e3b..0b4073f6b37e 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -3306,7 +3306,11 @@ proc getNullValueAux(p: BProc; t: PType; obj, constOrNil: PNode, var branchInit: StructInitializer result.addStructInitializer(branchInit, kind = siNamedStruct): result.addField(branchInit, name = fieldName): - getNullValueAux(p, t, b, constOrNil, result, branchInit, isConst, info) + # we need to generate the default value of the single sym, + # to do this create a dummy wrapper initializer and recurse + var branchFieldInit: StructInitializer + result.addStructInitializer(branchFieldInit, kind = siWrapper): + getNullValueAux(p, t, b, constOrNil, result, branchFieldInit, isConst, info) else: # no fields, don't initialize return