Shopify / tapioca

The swiss army knife of RBI generation
MIT License
720 stars 120 forks source link

Investigation: does Tapioca attempt to reference private constants? #978

Open egiurleo opened 2 years ago

egiurleo commented 2 years ago

Tapioca skips generating RBIs for private Sorbet constants. However, we are seeing instances of those constants being referenced in sorbet typechecks on projects with RBI generated by tapioca.

See gist: https://gist.github.com/rafaelfranca/ff4e9ba1fce3a53320268e1b01790d9c

It's not clear if this is a reproduce-able problem or what is causing it -- more investigation needed.

paracycle commented 2 years ago

I figured out why this was happening. It is because the gem defines a new constant under the T::Props namespace, which suddenly makes T and T::Props symbols as coming from that gem, so them and their subconstants get processed. This, coupled with the fact that we are still not perfectly filtering constants not defined in a gem, leads to this problem.

If we are after an ad-hoc solution, we can easily skip T::Props::Private and any subconstant from being processed, until we find a better solution.