4 ms·
Prediction: Coming soon to every language and IDE.
by rrobukef 5y ago
Prediction: Coming soon to every language and IDE.
- ithkuil 5y agoThis kind of analysis is not quite possible to perform with all languages. With some languages doing this kind of data flow analysis basically requires you to run the code and as soon as you perform IO you're out of luck.
- wcrichton 5y agoThis is right -- the analysis here uses aspects of Rust which don't exist in other languages. Specifically, transitive mutability markers (&T vs. &mut T) and lifetime-based alias-analysis.
- baq 5y agosurely you could guess some of that some of the time? no idea, have zero experience in the space, but it doesn't sound completely impossible.
- ithkuil 5y agosure you can guess; it all depends how much do you care if you cat't really trust that your IDE tells you.
- pornel 5y agoThere are many cases where such analysis quickly becomes exponentially expensive (e.g. nested loops or ifs) and/or requires analyzing whole program at once (to know whether anything anywhere might be holding a reference to the value you're checking), and there are patterns of code that are provably impossible to analyze (halting problem). There are static analyzers that try their best getting this data, but with arbitrary references without clearly annotated lifetimes that can very often become a stack of "well, it depends" to the point the analysis has to give up. Deduction of lifetimes in statically-typed languages without a borrow checker is very similar to deduction of types in dynamically-typed programs.