Closed rhiroe closed 2 weeks ago
0
is still an Integer
. To support the concept of non-zero, we’d need #1875.
It’s strange, however, that this situation leads to UnresolvedOverloading
. Integer
should be able to +
either Integer
or Float
.
Integer + (Integer | Float) -> (Integer | Float)
@ParadoxV5
0
is still anInteger
You are right.
However, if the argument is 0
, Float
is returned here.
https://github.com/ruby/rbs/blob/9244cd679c2abde430b465a7235f4daa35f94cbc/core/kernel.rbs#L1321
Thus, Integer
here should come to a non-zero integer, right?
https://github.com/ruby/rbs/blob/9244cd679c2abde430b465a7235f4daa35f94cbc/core/kernel.rbs#L1322
It should, but it doesn’t. That’s what #1875 was about.
It made sense to me.
Because it always returns Integer for non-zero integer values.
Background
Running steep check, this causes
UnresolvedOverloading
.Writing an expression like this seems to cause
UnresolvedOverloading
.Although not a direct solution, this problem can be avoided if the possibility of a Float being returned when the argument is a non-zero integer can be eliminated.
Thank you.