Sorbet Ruby LSP Guessed type TypeProf solargraph Reasonable type inference Haven't heard of large-scale adoption Depends on gem-side RBS availability How much depends on type declarations Quality of provided type information
Guessed type TypeProf solargraph Close to what I want Lack of Hash, Array inside info Overlaps with ruby-lsp Steep / Sorbet How much depends on type declarations Quality of provided type information
Guessed type TypeProf solargraph Support simple inference like: var name “user” to “User” class Steep / Sorbet How much depends on type declarations Quality of provided type information
code is used (list of called methods). Experiment on 3 large Rails projects at work: - Collect all method calls per variable / argument - Filter candidates which have all called methods per var / arg - Count vars / args that get only one candidate. -> achieved ~10-20% estimation.
objects receive "==", "to_s", then it will match all registered Class, 60% of slow inferences came from here. Exception: instance methods of "Object" 30
Assume that some objects receive "==", "to_s", then it will match all registered Class, 60% of slow inferences came from here. Solution: Excludes instance methods of "Object" class on duck typing heuristic. End with "untyped" if node only receives "Object" methods ASAP.
- Just providing type info, ruby-lsp will handle text on hover, candidate on autocompletion, def jump… - Get methods generated by DSL from other add-on, such as ruby-lsp-rails - …or so I thought. Impl as ruby-lsp add on 42
requested with cache - some gems are very slow to infer/parse as they have too many files. so with gems: - Collect constant and its method on indexing time. - Building IR nodes, inferring lazy. Lazy Inference 46
via "bin/rails" and dynamically dispatches from there(via RuntimeClient). Class methods land in the code index, but model attribute info doesn't. It fetches information when requested. How do existing tools handle this? 53
ideally doesn't want to add RBS to the codebase. - Decide to embed ActiveRecord-aware logic internally (experimental) - trust ActiveRecord's interface stability for now - Eventually we want a registration API to externalize this — future work. - or… 54
20s with ruby-lsp. Inference under 2s without cache. Under 1s when warm. - "An LSP must not interfere with editor operations" - Most inference done in 100-200ms - It's only occasionally slow… Note: Benchmarks and coverage reports are in the repo
list is critical, otherwise everything falls into untyped - Diagnostic is hard - Information to validate and information to aid inference are tangled together — still figuring this out - First step might be just to give warning when there is no matched constants? Limitation 62
be considered as a user of type-guessr. Published as an MCP (Model Context Protocol) server: 3 tools - infer_type - get_method_signature - search_methods But, wait, do we really need it? 64
CC with ruby-lsp with prompt encourage to use it - CC with type-guessr MCP - CC with type-guessr MCP with prompt encourage to use it Experiment for fun 65
- 2. Resolve AR column / association types - 3. Detect DSL-generated methods (scope, enum) - 4. Disambiguate same-name methods across classes - 5. Infer Hash Record type - 6. Follow methods through include / extend - 7. Fix plan for method on one side of Union 66 Experiment for fun
types - "Good Enough" has real value…? - at least to me - try it: "gem install type-guessr" (& "gem install ruby-lsp") - https://github.com/riseshia/type-guessr Conclusion 68