Skip to content

Commit

Permalink
still need wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Oct 15, 2024
1 parent df5aa30 commit c71ae94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/cbuilderdecls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 }`
Expand Down
6 changes: 5 additions & 1 deletion compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c71ae94

Please sign in to comment.