diff options
-rw-r--r-- | compiler/ccgexprs.nim | 7 | ||||
-rw-r--r-- | tests/destructor/tsimpletable.nim | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 22951b4cb..273117bc7 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2709,9 +2709,14 @@ proc getDefaultValue(p: BProc; typ: PType; info: TLineInfo): Rope = of tyBool: result = rope"NIM_FALSE" of tyEnum, tyChar, tyInt..tyInt64, tyUInt..tyUInt64: result = rope"0" of tyFloat..tyFloat128: result = rope"0.0" - of tyCString, tyString, tyVar, tyLent, tyPointer, tyPtr, tySequence, tyUntyped, + of tyCString, tyVar, tyLent, tyPointer, tyPtr, tyUntyped, tyTyped, tyTypeDesc, tyStatic, tyRef, tyNil: result = rope"NIM_NIL" + of tyString, tySequence: + if p.config.selectedGC == gcDestructors: + result = rope"{0, NIM_NIL}" + else: + result = rope"NIM_NIL" of tyProc: if t.callConv != ccClosure: result = rope"NIM_NIL" diff --git a/tests/destructor/tsimpletable.nim b/tests/destructor/tsimpletable.nim index d32fe51cb..34a4ac063 100644 --- a/tests/destructor/tsimpletable.nim +++ b/tests/destructor/tsimpletable.nim @@ -20,6 +20,14 @@ proc main = main() +# bug #11745 + +type + Foo = object + bar: seq[int] + +var x = [Foo()] + # bug #11563 type MyTypeType = enum |