diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index aaf60a6cbff2..fb29a99076c2 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -9,6 +9,10 @@ # included from cgen.nim +proc getNullValueAuxT(p: BProc; orig, t: PType; obj, constOrNil: PNode, + result: var Rope; count: var int; + isConst: bool, info: TLineInfo) + # -------------------------- constant expressions ------------------------ proc int64Literal(i: BiggestInt): Rope = @@ -2742,11 +2746,10 @@ proc getDefaultValue(p: BProc; typ: PType; info: TLineInfo): Rope = else: result = rope"{NIM_NIL, NIM_NIL}" of tyObject: - # XXX Needs to be recursive! - if not isObjLackingTypeField(t): - result = "{{$1}}" % [genTypeInfo(p.module, t, info)] - else: - result = rope"{}" + var count = 0 + result.add "{" + getNullValueAuxT(p, t, t, t.n, nil, result, count, true, info) + result.add "}" of tyTuple: result = rope"{" for i in 0.. 0: result.add ", " - result.add "{{" # struct inside union # XXX select default case branch here! #for i in 1.. 0: result.add ", " inc count let field = obj.sym - for i in 1..