steep
steep copied to clipboard
Steep does not support inverting a boolish value
I noticed Steep emit a warning for the code inverting a boolish value. This is bad result.
# app.rbs
module Kernel
def hello?: () -> boolish
end
# app.rb
p :hello if !hello?
$ bundle exec steep check
# Type checking files:
..................................................................................F.
app/app.rb:1:12: [error] Type `top` does not have method `!`
│ Diagnostic ID: Ruby::NoMethod
│
└ p :hello if !hello?
~
Detected 1 problem from 1 file
Should boolish be untyped instead?
def my_method: (boolish) -> boolish
# in = contravariant ^ ^ out = covariant
I feel changing boolish as an alias for untyped is not a good idea. Because the main usage of the boolish type is a condition clause. No methods except ! should not be allowed. Therefore it's better to keep it as an alias for top to me.
I agree that top and boolish are not the same. So it would be better to add another top-like type for boolish. But we need to work hard to do that...