Open alexanderjsummers opened 6 years ago
Interesting. This does seem like a case where SSA-style rewriting would help; I wonder if there is another solution. The constraints that arise are roughly like this:
'b1: 'list @ START/2
'list: 'v @ START/3
'b2: 'v @ START/3
'b3: 'list @ START/4
Ignoring 'v
, the first constraint would not ordinarily add START/6
into 'b1
, because it would not be reachable from 'b1
(that is, ignoring 'v
, 'b1
would not contain START/4). However, in this case, we wind up adding START/4
and START/5
into 'b1
from 'v
, which then forms a path from the borrow of 'b1
to START/6
.
This is an interesting effect. I'm not sure how best to fix it.
In the following code, it doesn't seem correct that the first Loan struct computed includes the line
START/6
- it seems that that value oflist
is dead by that point, and the lifetime of the borrow onx
shouldn't extend beyond the penultimate statement.