3 ms·
> It’s odd to do this sort of flow-sensitive analysis on the CFG for a language feature that affects whether code is accepted or rejected Is this something new
by lolinder 3y ago
> It’s odd to do this sort of flow-sensitive analysis on the CFG for a language feature that affects whether code is accepted or rejected
Is this something new here with this rendition of the borrow checker? I thought the whole premise of the borrow checker was to do a data flow analysis, decide whether to accept or reject the program, and if necessary to provide information about why the program was rejected.
It looks like what this project is trying to accomplish is to use better control flow mapping to reduce the number of unnecessary rejections that programmers see.
- rayiner 3y agoUntil last year, the borrow checker operated on lexical scopes, which are apparent in the source code and the programmer can reason about. Last year, the borrow checker was changed to support non-lexical lifetimes by operating on the control flow graph—something the programmer never sees and is hard to reason about. This project continues running further in that direction, making it harder for the programmer to understand why the borrow checker does what it does.
- ForkMeOnTinder 3y agoThe new implementations are more permissive than the old ones*. So if your program is rejected, it would have been rejected under the old, simpler implementation as well, and you can use your intuition of the simpler rules to understand why. *excluding bugfixes, of course What's actually hard to reason about is problem cases like in TFA which seem like they should be valid, but the compiler rejects anyway. These are cases where people's intuition doesn't match the current implementation, so I think moving the implementation closer to people's mental model of borrowing will make the language easier.