steep
steep copied to clipboard
Treat `present?` as a special method that guarantees the receiver is not nil
Fixes https://github.com/soutaro/steep/issues/472
The pull request https://github.com/soutaro/steep/pull/905 attempts to resolve the issue using annotations, but this PR resolves it by treating present? as a special method, similar to how Sorbet handles it https://github.com/sorbet/sorbet/blob/718bc64f895abeeff88f56efbc92a3554ffaa4f2/infer/environment.cc#L564-L579
Thank you for opening this PR. I think there are two things to consider:
- It's not
ReceiverIsNotNil. IntroducingReceiverIsPresentor something would be better. (And because the negation doesn't mean it'snil, the implementation should be revised.) - I'm not very sure if we should have this implementation in Steep. It's not a part of Ruby. The semantics look like too complicated.
Do we need steep-rails?
We can support these non-Ruby methods by extending RBS types where we can directly write something like:
def present?: () -> self is not blank