rbi icon indicating copy to clipboard operation
rbi copied to clipboard

Const holds a type rather than a value

Open Morriar opened this issue 9 months ago • 1 comments

Follow up on https://github.com/Shopify/rbi/pull/408#issuecomment-2755037767.

In the context of an RBI file, does it really make sense to hold the value of constants?

This PR proposes to change Const so it only stores the type we find a the T.let if any.

So this:

A = 42
B = T.let(42, Integer)
C = foo(T.let(42, Integer))

gives this:

A = T.let(T.unsafe(nil), T.untyped)
B = T.let(T.unsafe(nil), Integer)
C = T.let(T.unsafe(nil), T.untyped)

This is quite a breaking change for the gem's API and should be released with at least a minor version bump.

I think we can apply the same logic to optional positional and keyword parameters 🤔

Morriar avatar Mar 28 '25 14:03 Morriar

Given it's a breaking change, can the description also include the benefits it will bring too?

st0012 avatar Mar 28 '25 20:03 st0012