Steep can't deal with arithmetic operators when both operands are union types of standard numbers.
This can easily be seen with code like this:
class Test
def mul(value, other)
value * other
end
def mul1(value, other)
value * other
end
def mul2(value, other)
value * other
end
def div(value, other)
value / other
end
def add(value, other)
value + other
end
def sub(value, other)
value - other
end
end
and signatures like this:
# type real = Integer | Float | Rational
class Test
def mul: (real, real) -> real
def mul1: (Rational, real) -> real
def mul2: (real, Float) -> real
def div: (real, real) -> real
def add: (real, real) -> real
def sub: (real, real) -> real
end
While mul1 and mul2 do no generate any errors or warnings, all other methods cause an error similar to
(I'm working with enabled "bigdecimal" library, but it doesn't really matter, it just increases the number of overloads.)
Clearly, any pair of Integer, Float, Rational (and BigDecimal) produces a defined result in reality, so typing should also work, but it doesn't. The only way that seems to work is to change of the parameters to a concrete type, like def mul: (Float, real) -> real, but this defies the point of writing method types.
Steep can't deal with arithmetic operators when both operands are union types of standard numbers.
This can easily be seen with code like this:
and signatures like this:
While
mul1
andmul2
do no generate any errors or warnings, all other methods cause an error similar to(I'm working with enabled "bigdecimal" library, but it doesn't really matter, it just increases the number of overloads.)
Clearly, any pair of Integer, Float, Rational (and BigDecimal) produces a defined result in reality, so typing should also work, but it doesn't. The only way that seems to work is to change of the parameters to a concrete type, like
def mul: (Float, real) -> real
, but this defies the point of writing method types.