* fix #19435; openArray wronyly registers typebounds * add testcase * don't create TypeBoundOps for tyOpenArray, tyVarargs
This commit is contained in:
parent
8e6136dd59
commit
efaa6777a4
2 changed files with 30 additions and 1 deletions
|
|
@ -1054,7 +1054,7 @@ proc track(tracked: PEffects, n: PNode) =
|
||||||
addAsgnFact(tracked.guards, n[0], n[1])
|
addAsgnFact(tracked.guards, n[0], n[1])
|
||||||
notNilCheck(tracked, n[1], n[0].typ)
|
notNilCheck(tracked, n[1], n[0].typ)
|
||||||
when false: cstringCheck(tracked, n)
|
when false: cstringCheck(tracked, n)
|
||||||
if tracked.owner.kind != skMacro:
|
if tracked.owner.kind != skMacro and n[0].typ.kind notin {tyOpenArray, tyVarargs}:
|
||||||
createTypeBoundOps(tracked, n[0].typ, n.info)
|
createTypeBoundOps(tracked, n[0].typ, n.info)
|
||||||
if n[0].kind != nkSym or not isLocalVar(tracked, n[0].sym):
|
if n[0].kind != nkSym or not isLocalVar(tracked, n[0].sym):
|
||||||
checkForSink(tracked.config, tracked.c.idgen, tracked.owner, n[1])
|
checkForSink(tracked.config, tracked.c.idgen, tracked.owner, n[1])
|
||||||
|
|
|
||||||
29
tests/arc/t19435.nim
Normal file
29
tests/arc/t19435.nim
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
discard """
|
||||||
|
matrix: "--gc:arc"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #19435
|
||||||
|
{.experimental: "views".}
|
||||||
|
|
||||||
|
type
|
||||||
|
Bar = object
|
||||||
|
placeholder: int
|
||||||
|
Foo = object
|
||||||
|
placeholder: int
|
||||||
|
c: seq[Bar] # remove this line to make things right
|
||||||
|
|
||||||
|
func children*(s: var seq[Foo]): openArray[Foo] =
|
||||||
|
s.toOpenArray(0, s.len-1)
|
||||||
|
|
||||||
|
proc test =
|
||||||
|
var foos = @[Foo(), Foo()]
|
||||||
|
|
||||||
|
assert foos.children.len == 2
|
||||||
|
var flag = true
|
||||||
|
for a in foos.children:
|
||||||
|
flag = false
|
||||||
|
|
||||||
|
if flag:
|
||||||
|
doAssert false
|
||||||
|
|
||||||
|
test()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue