From 67a6effb7bf4d319c8bafd65c75a4da47e007c24 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 19 Jul 2019 22:38:35 +0200 Subject: [PATCH] fixes #11745 --- compiler/ccgexprs.nim | 7 ++++++- tests/destructor/tsimpletable.nim | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 22951b4cb8..273117bc70 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 d32fe51cb2..34a4ac0634 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