Find Related products on Amazon

Shop on Amazon

Interprocedural Sparse Conditional Type Propagation

Published on: 2025-06-18 21:44:25

It’s 11 o’clock. Do you know where your variables are pointing? def shout ( obj ) obj . to_s + "!" end It’s hard to tell just looking at the code what type obj is. We assume it has a to_s method, but many classes define methods named to_s . Which to_s method are we calling? What is the return type of shout ? If to_s doesn’t return a String , it’s really hard to say. Adding type annotations would help… a little. With types, it looks like we have full knowledge about what each thing is but we actually don’t. Ruby, like many other object-oriented languages, has this thing called inheritance which means that type signatures like Integer and String mean an instance of that class… or an instance of a subclass of that class. Additionally, gradual type checkers such as Sorbet (for example) have features such as T.unsafe and T.untyped which make it possible to lie to the type checker. These annotations unfortunately render the type system unsound without run-time type checks, which makes it ... Read full article.