fixes a long-standing ARC bug (#20849)
* fixes an ARC bug * add a testcase
This commit is contained in:
parent
4a3be7e29e
commit
3d692d08f7
2 changed files with 18 additions and 2 deletions
|
|
@ -63,6 +63,8 @@ proc aliases*(obj, field: PNode): AliasKind =
|
||||||
# x.f -> x: false
|
# x.f -> x: false
|
||||||
# x.f -> x.f: true
|
# x.f -> x.f: true
|
||||||
# x.f -> x.v: false
|
# x.f -> x.v: false
|
||||||
|
# x -> x[]: true
|
||||||
|
# x[] -> x: false
|
||||||
# x -> x[0]: true
|
# x -> x[0]: true
|
||||||
# x[0] -> x: false
|
# x[0] -> x: false
|
||||||
# x[0] -> x[0]: true
|
# x[0] -> x[0]: true
|
||||||
|
|
@ -76,11 +78,11 @@ proc aliases*(obj, field: PNode): AliasKind =
|
||||||
var n = n
|
var n = n
|
||||||
while true:
|
while true:
|
||||||
case n.kind
|
case n.kind
|
||||||
of PathKinds0 - {nkDotExpr, nkBracketExpr}:
|
of PathKinds0 - {nkDotExpr, nkBracketExpr, nkDerefExpr, nkHiddenDeref}:
|
||||||
n = n[0]
|
n = n[0]
|
||||||
of PathKinds1:
|
of PathKinds1:
|
||||||
n = n[1]
|
n = n[1]
|
||||||
of nkDotExpr, nkBracketExpr:
|
of nkDotExpr, nkBracketExpr, nkDerefExpr, nkHiddenDeref:
|
||||||
result.add n
|
result.add n
|
||||||
n = n[0]
|
n = n[0]
|
||||||
of nkSym:
|
of nkSym:
|
||||||
|
|
@ -114,6 +116,8 @@ proc aliases*(obj, field: PNode): AliasKind =
|
||||||
if currFieldPath.sym != currObjPath.sym: return no
|
if currFieldPath.sym != currObjPath.sym: return no
|
||||||
of nkDotExpr:
|
of nkDotExpr:
|
||||||
if currFieldPath[1].sym != currObjPath[1].sym: return no
|
if currFieldPath[1].sym != currObjPath[1].sym: return no
|
||||||
|
of nkDerefExpr, nkHiddenDeref:
|
||||||
|
discard
|
||||||
of nkBracketExpr:
|
of nkBracketExpr:
|
||||||
if currFieldPath[1].kind in nkLiterals and currObjPath[1].kind in nkLiterals:
|
if currFieldPath[1].kind in nkLiterals and currObjPath[1].kind in nkLiterals:
|
||||||
if currFieldPath[1].intVal != currObjPath[1].intVal:
|
if currFieldPath[1].intVal != currObjPath[1].intVal:
|
||||||
|
|
|
||||||
|
|
@ -546,3 +546,15 @@ proc fooz(sec: var InputSectionBase) =
|
||||||
var sec = create(InputSection)
|
var sec = create(InputSection)
|
||||||
sec[] = InputSection(relocations: newSeq[int]())
|
sec[] = InputSection(relocations: newSeq[int]())
|
||||||
fooz sec[]
|
fooz sec[]
|
||||||
|
|
||||||
|
block:
|
||||||
|
type
|
||||||
|
Data = ref object
|
||||||
|
id: int
|
||||||
|
proc main =
|
||||||
|
var x = Data(id: 99)
|
||||||
|
var y = x
|
||||||
|
x[] = Data(id: 778)[]
|
||||||
|
doAssert y.id == 778
|
||||||
|
doAssert x[].id == 778
|
||||||
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue