fixes move analyser; refs #11257
This commit is contained in:
parent
981f95757c
commit
b75ad05267
2 changed files with 17 additions and 5 deletions
|
|
@ -178,13 +178,13 @@ proc isLastRead(location: PNode; c: var Con; pc, comesFrom: int): int =
|
|||
pc = pc + c.g[pc].dest
|
||||
of fork:
|
||||
# every branch must lead to the last read of the location:
|
||||
var variantA = isLastRead(location, c, pc+1, pc)
|
||||
let variantA = isLastRead(location, c, pc+1, pc)
|
||||
if variantA < 0: return -1
|
||||
let variantB = isLastRead(location, c, pc + c.g[pc].dest, pc)
|
||||
var variantB = isLastRead(location, c, pc + c.g[pc].dest, pc)
|
||||
if variantB < 0: return -1
|
||||
elif variantA == high(int):
|
||||
variantA = variantB
|
||||
pc = variantA
|
||||
elif variantB == high(int):
|
||||
variantB = variantA
|
||||
pc = variantB
|
||||
of InstrKind.join:
|
||||
let dest = pc + c.g[pc].dest
|
||||
if dest == comesFrom: return pc + 1
|
||||
|
|
|
|||
12
tests/destructor/tconsume_twice.nim
Normal file
12
tests/destructor/tconsume_twice.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
discard """
|
||||
cmd: "nim c --newruntime $file"
|
||||
errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(8, 6)"
|
||||
line: 10
|
||||
"""
|
||||
|
||||
proc consumeTwice(a: owned proc()): owned proc() =
|
||||
if a == nil:
|
||||
return
|
||||
return a
|
||||
|
||||
assert consumeTwice(proc() = discard) != nil
|
||||
Loading…
Add table
Add a link
Reference in a new issue