mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 05:53:22 +00:00
* fix #15428
* add test
(cherry picked from commit af3fd5a010)
This commit is contained in:
@@ -444,9 +444,10 @@ proc genDeepCopy(p: BProc; dest, src: TLoc) =
|
||||
[addrLoc(p.config, dest), rdLoc(src),
|
||||
genTypeInfoV1(p.module, dest.t, dest.lode.info)])
|
||||
of tyOpenArray, tyVarargs:
|
||||
let source = addrLocOrTemp(src)
|
||||
linefmt(p, cpsStmts,
|
||||
"#genericDeepCopyOpenArray((void*)$1, (void*)$2, $1Len_0, $3);$n",
|
||||
[addrLoc(p.config, dest), addrLocOrTemp(src),
|
||||
"#genericDeepCopyOpenArray((void*)$1, (void*)$2, $2->Field1, $3);$n",
|
||||
[addrLoc(p.config, dest), source,
|
||||
genTypeInfoV1(p.module, dest.t, dest.lode.info)])
|
||||
of tySet:
|
||||
if mapSetType(p.config, ty) == ctArray:
|
||||
|
||||
22
tests/ccgbugs/t15428.nim
Normal file
22
tests/ccgbugs/t15428.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
discard """
|
||||
cmd: "nim $target --mm:refc $file"
|
||||
output: '''5
|
||||
5
|
||||
[1, 2, 3, 4, 5]
|
||||
(data: [1, 2, 3, 4, 5])
|
||||
'''
|
||||
"""
|
||||
|
||||
proc take[T](f: openArray[T]) =
|
||||
echo f.len
|
||||
let f = @[0,1,2,3,4]
|
||||
take(f.toOpenArray(0,4))
|
||||
|
||||
{.experimental: "views".}
|
||||
type
|
||||
Foo = object
|
||||
data: openArray[int]
|
||||
let f2 = Foo(data: [1,2,3,4,5])
|
||||
echo f2.data.len
|
||||
echo f2.data
|
||||
echo f2
|
||||
Reference in New Issue
Block a user