diff options
-rw-r--r-- | compiler/ccgexprs.nim | 2 | ||||
-rw-r--r-- | tests/destructor/tv2_cast.nim | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 58a45f1f5..baf51a8f2 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1839,7 +1839,7 @@ proc genSomeCast(p: BProc, e: PNode, d: var TLoc) = if srcTyp.kind in {tyPtr, tyPointer} and etyp.kind in IntegralTypes: putIntoDest(p, d, e, "(($1) (ptrdiff_t) ($2))" % [getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage) - elif p.config.selectedGc == gcDestructors and etyp.kind == tySequence: + elif p.config.selectedGc == gcDestructors and etyp.kind in {tySequence, tyString}: putIntoDest(p, d, e, "(*($1*) (&$2))" % [getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage) else: diff --git a/tests/destructor/tv2_cast.nim b/tests/destructor/tv2_cast.nim index 1430b7521..82c03fb17 100644 --- a/tests/destructor/tv2_cast.nim +++ b/tests/destructor/tv2_cast.nim @@ -1,7 +1,9 @@ discard """ cmd: '''nim c --newruntime $file''' output: '''@[1] -@[116, 101, 115, 116]''' +@[116, 101, 115, 116] +test +@[1953719668, 875770417]''' """ # bug #11018 @@ -9,3 +11,9 @@ discard cast[seq[uint8]](@[1]) discard cast[seq[uint8]]("test") echo cast[seq[uint8]](@[1]) echo cast[seq[uint8]]("test") + +discard cast[string](@[116'u8, 101, 115, 116]) +echo cast[string](@[116'u8, 101, 115, 116]) +var a = cast[seq[uint32]]("test1234") +a.setLen(2) +echo a |