Fix 15629 (#15888)
* fix #15858 * fix space * fix #15629 * Revert "fix space" * Revert "fix #15858"
This commit is contained in:
parent
d5a0a5dfff
commit
69fe707025
2 changed files with 40 additions and 12 deletions
|
|
@ -45,6 +45,8 @@ proc `<`(a, b: AbstractTime): bool {.borrow.}
|
||||||
proc inc(x: var AbstractTime; diff = 1) {.borrow.}
|
proc inc(x: var AbstractTime; diff = 1) {.borrow.}
|
||||||
proc dec(x: var AbstractTime; diff = 1) {.borrow.}
|
proc dec(x: var AbstractTime; diff = 1) {.borrow.}
|
||||||
|
|
||||||
|
proc `$`(x: AbstractTime): string {.borrow.}
|
||||||
|
|
||||||
type
|
type
|
||||||
SubgraphFlag = enum
|
SubgraphFlag = enum
|
||||||
isMutated, # graph might be mutated
|
isMutated, # graph might be mutated
|
||||||
|
|
@ -592,32 +594,33 @@ proc deps(c: var Partitions; dest, src: PNode) =
|
||||||
connect(c, t, s, dest.info)
|
connect(c, t, s, dest.info)
|
||||||
|
|
||||||
if cursorInference in c.goals and src.kind != nkEmpty:
|
if cursorInference in c.goals and src.kind != nkEmpty:
|
||||||
if dest.kind == nkSym:
|
let d = pathExpr(dest, c.owner)
|
||||||
let vid = variableId(c, dest.sym)
|
if d != nil and d.kind == nkSym:
|
||||||
|
let vid = variableId(c, d.sym)
|
||||||
if vid >= 0:
|
if vid >= 0:
|
||||||
destMightOwn(c, c.s[vid], src)
|
destMightOwn(c, c.s[vid], src)
|
||||||
for s in sources:
|
for s in sources:
|
||||||
if s == dest.sym:
|
if s == d.sym:
|
||||||
discard "assignments like: it = it.next are fine"
|
discard "assignments like: it = it.next are fine"
|
||||||
elif {sfGlobal, sfThread} * s.flags != {} or hasDisabledAsgn(s.typ):
|
elif {sfGlobal, sfThread} * s.flags != {} or hasDisabledAsgn(s.typ):
|
||||||
# do not borrow from a global variable or from something with a
|
# do not borrow from a global variable or from something with a
|
||||||
# disabled assignment operator.
|
# disabled assignment operator.
|
||||||
c.s[vid].flags.incl preventCursor
|
c.s[vid].flags.incl preventCursor
|
||||||
when explainCursors: echo "A not a cursor: ", dest.sym, " ", s
|
when explainCursors: echo "A not a cursor: ", d.sym, " ", s
|
||||||
else:
|
else:
|
||||||
let srcid = variableId(c, s)
|
let srcid = variableId(c, s)
|
||||||
if srcid >= 0:
|
if srcid >= 0:
|
||||||
if s.kind notin {skResult, skParam} and (
|
if s.kind notin {skResult, skParam} and (
|
||||||
c.s[srcid].aliveEnd < c.s[vid].aliveEnd):
|
c.s[srcid].aliveEnd < c.s[vid].aliveEnd):
|
||||||
# you cannot borrow from a local that lives shorter than 'vid':
|
# you cannot borrow from a local that lives shorter than 'vid':
|
||||||
when explainCursors: echo "B not a cursor ", dest.sym, " ", c.s[srcid].aliveEnd, " ", c.s[vid].aliveEnd
|
when explainCursors: echo "B not a cursor ", d.sym, " ", c.s[srcid].aliveEnd, " ", c.s[vid].aliveEnd
|
||||||
c.s[vid].flags.incl preventCursor
|
c.s[vid].flags.incl preventCursor
|
||||||
elif {isReassigned, preventCursor} * c.s[srcid].flags != {}:
|
elif {isReassigned, preventCursor} * c.s[srcid].flags != {}:
|
||||||
# you cannot borrow from something that is re-assigned:
|
# you cannot borrow from something that is re-assigned:
|
||||||
when explainCursors: echo "C not a cursor ", dest.sym, " ", c.s[srcid].flags, " reassignedTo ", c.s[srcid].reassignedTo
|
when explainCursors: echo "C not a cursor ", d.sym, " ", c.s[srcid].flags, " reassignedTo ", c.s[srcid].reassignedTo
|
||||||
c.s[vid].flags.incl preventCursor
|
c.s[vid].flags.incl preventCursor
|
||||||
elif c.s[srcid].reassignedTo != 0 and c.s[srcid].reassignedTo != dest.sym.id:
|
elif c.s[srcid].reassignedTo != 0 and c.s[srcid].reassignedTo != d.sym.id:
|
||||||
when explainCursors: echo "D not a cursor ", dest.sym, " reassignedTo ", c.s[srcid].reassignedTo
|
when explainCursors: echo "D not a cursor ", d.sym, " reassignedTo ", c.s[srcid].reassignedTo
|
||||||
c.s[vid].flags.incl preventCursor
|
c.s[vid].flags.incl preventCursor
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''emptyemptyempty'''
|
|
||||||
cmd: '''nim c --gc:arc $file'''
|
cmd: '''nim c --gc:arc $file'''
|
||||||
|
output: '''emptyemptyempty
|
||||||
|
inner destroy
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# bug #15039
|
# bug #15039
|
||||||
|
|
@ -49,3 +51,26 @@ proc parse() =
|
||||||
echo children
|
echo children
|
||||||
|
|
||||||
parse()
|
parse()
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# issue #15629
|
||||||
|
|
||||||
|
type inner = object
|
||||||
|
type outer = ref inner
|
||||||
|
|
||||||
|
proc `=destroy`(b: var inner) =
|
||||||
|
echo "inner destroy"
|
||||||
|
|
||||||
|
proc newOuter(): outer =
|
||||||
|
new(result)
|
||||||
|
|
||||||
|
type holder = object
|
||||||
|
contents: outer
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
var t: holder
|
||||||
|
t.contents = newOuter()
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue