Finer analysis for array access (#16787)
* Refine the analysis for array access * Cleanup * Add comments
This commit is contained in:
parent
8241e55023
commit
301e5838ec
3 changed files with 106 additions and 29 deletions
|
|
@ -92,10 +92,20 @@ copy
|
|||
destroy
|
||||
destroy
|
||||
destroy
|
||||
sink
|
||||
sink
|
||||
destroy
|
||||
copy
|
||||
(f: 1)
|
||||
destroy
|
||||
destroy
|
||||
part-to-whole assigment:
|
||||
sink
|
||||
(children: @[])
|
||||
destroy
|
||||
sink
|
||||
(children: @[])
|
||||
destroy
|
||||
copy
|
||||
destroy
|
||||
'''
|
||||
|
|
@ -675,6 +685,16 @@ proc caseNotAConstant =
|
|||
|
||||
caseNotAConstant()
|
||||
|
||||
proc potentialSelfAssign(i: var int) =
|
||||
var a: array[2, OO]
|
||||
a[i] = OO(f: 1)
|
||||
a[1] = OO(f: 2)
|
||||
a[i+1] = a[i] # This must not =sink, but =copy
|
||||
inc i
|
||||
echo a[i-1] # (f: 1)
|
||||
|
||||
potentialSelfAssign (var xi = 0; xi)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
echo "part-to-whole assigment:"
|
||||
|
|
@ -700,6 +720,17 @@ proc partToWholeSeq =
|
|||
|
||||
partToWholeSeq()
|
||||
|
||||
proc partToWholeSeqRTIndex =
|
||||
var i = 0
|
||||
var t = Tree(children: @[Tree()])
|
||||
t = t.children[i] # See comment in partToWholeSeq
|
||||
|
||||
var tc = TreeDefaultHooks(children: @[TreeDefaultHooks()])
|
||||
tc = tc.children[i] # See comment in partToWholeSeq
|
||||
echo tc
|
||||
|
||||
partToWholeSeqRTIndex()
|
||||
|
||||
type List = object
|
||||
next: ref List
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue