Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mathematical operations don't play well with BigDecimal #1052

Closed
piotaixr opened this issue Jul 1, 2022 · 0 comments · Fixed by #1053
Closed

Mathematical operations don't play well with BigDecimal #1052

piotaixr opened this issue Jul 1, 2022 · 0 comments · Fixed by #1053

Comments

@piotaixr
Copy link
Contributor

piotaixr commented Jul 1, 2022

I am trying to add typings to a ruby library that has a method like:

# def my_method: (Integer int) -> BigDecimal
def my_method(int)
  int / BigDecimal(2)
end

The current signature of Integer#/ is:

  def /: (Integer) -> Integer
       | (Float) -> Float
       | (Rational) -> Rational
       | (Complex) -> Complex

However, when using BigDecimal, it should be:

  def /: (Integer) -> Integer
       | (Float) -> Float
       | (Rational) -> Rational
       | (Complex) -> Complex
       | (BigDecimal) -> BigDecimal

I'm not an expert in RBS, but it seems we cannot add an overload to an already defined method (or can we?).
Edit: Found it!

As Steep don't have the correct typings, it complains about it. rather loudly. I could write BigDecimal(int) / BigDecimal(2) to silence it, but if there is an alternative, I'm all for it!

I'm doing a PR to add the definitions to the big_decimal.rbs typings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant