Hacker News new | ask | show | jobs
by falcolas 1465 days ago
Is this a serious question? Code analysis (both static and dynamic).

The same way Rust checks for object lifespans with the borrow checker, which is distinct from the compiler and type system.

The same way valgrind for C can check for use after free.

The same way errorprone can look for null checks in Java.

This is a well tested and proven technique. Static code analysis is a staple of the industry, when it comes to automated code analysis.

2 comments

I still don't see how you can determine an object's attributes without type information. If you're inside the function, all you know is there's a parameter named item. How can you provide autocomplete there?

All of the examples you gave are from static languages, where the information is known at compile time (except for valgrind, which requires a runtime). The parent to my original post was claiming that you can have the same tooling for Ruby.

Also, you're wrong about Rust. Lifetimes are part of the type system.

Valgrind finding use-after-free is a dynamic analysis.