Good Enough Types: Heuristic Type Inference for Ruby
summary
A heuristic type-inference gem called Type Guesser infers Ruby types by collecting methods called on variables, applying a duck-typing-like heuristic and light method-local type flow, integrating as a ruby-lsp addon. It caches on-demand gem parsing, special-cases Object methods, aggregates instance-variable usages from outer scope, returns unions up to three candidates, and falls back to Untyped when four or more match. Measured inference coverage is roughly 40% (baseline 10–20%), startup ≈20s, warm <5s.
AI-written summary · about
chapters (11)
- 0:00Introduction and motivation
- 3:41Existing type tools in Ruby
- 6:14Heuristic type inference idea
- 9:50Type Guesser implementation
- 16:51Architecture and design choices
- 20:29Handling gem dependencies
- 22:22DSL support challenges
- 24:21Performance and metrics
- 26:34Limitations and future work
- 27:42AI integration with MCP
- 29:58Conclusion and call to action
related talks
15mSound, Heuristic Type Annotation Inference for Ruby
39mType Checking Ruby Programs with Annotations
28mA Plan towards Ruby 3 Types
37mTypes and Ruby Programming Language
37mChecking Your Types: An Overview of Ruby's Type System
14mSimTyper: Sound Type Inference for Ruby using Type Equality Prediction
32mDo LLMs dream of Type Inference?
53mAn introduction to typed Ruby programming
