mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
@@ -1839,6 +1839,9 @@ 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:
|
||||
putIntoDest(p, d, e, "(*($1*) (&$2))" %
|
||||
[getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage)
|
||||
else:
|
||||
putIntoDest(p, d, e, "(($1) ($2))" %
|
||||
[getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage)
|
||||
|
||||
11
tests/destructor/tv2_cast.nim
Normal file
11
tests/destructor/tv2_cast.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
discard """
|
||||
cmd: '''nim c --newruntime $file'''
|
||||
output: '''@[1]
|
||||
@[116, 101, 115, 116]'''
|
||||
"""
|
||||
|
||||
# bug #11018
|
||||
discard cast[seq[uint8]](@[1])
|
||||
discard cast[seq[uint8]]("test")
|
||||
echo cast[seq[uint8]](@[1])
|
||||
echo cast[seq[uint8]]("test")
|
||||
Reference in New Issue
Block a user