rbs icon indicating copy to clipboard operation
rbs copied to clipboard

Fix double-splat method

Open ksss opened this issue 1 year ago • 3 comments

Currently sleep(2 ** 2) results in a type error since 2 ** 2 returns Numeric type. Because of these problems, it does not seem very convenient to set the return value to Numeric in numerical operations.

In this PR, I have made similar fixes to #** as those in Integer#pow.

It has been exhaustively tested in raap because the combination is complicated.

ksss avatar Jun 25 '24 05:06 ksss

  • Resolves https://ptb.discord.com/channels/518658712081268738/1143338778384146574/1252966446221492256

+1 for the good intention, but we should keep the (Numeric) -> branch as math operators accept any Numeric that coerce appropriately.

For the intention, we should go through all files and check for Numeric usages and specify known cases as appropriate. Summon: @sampersand: you had PRs on numerics and they include making the sigs more ~~pedantic~~ exact.

ParadoxV5 avatar Jun 25 '24 05:06 ParadoxV5

@ParadoxV5 Thanks for the review. Indeed, with this change 1 ** BigDecimal(1) would result in a type error. What about the idea of extending Integer#** from BigDecimal? Like + or -.

# bigdecimal.rbs
class Integer
  def **: (BigDecimal) -> BigDecimal
        | ...
end

ksss avatar Jun 25 '24 06:06 ksss

  • Resolves https://ptb.discord.com/channels/518658712081268738/1143338778384146574/1252966446221492256

+1 for the good intention, but we should keep the (Numeric) -> branch as math operators accept any Numeric that coerce appropriately.

For the intention, we should go through all files and check for Numeric usages and specify known cases as appropriate. Summon: @sampersand: you had PRs on numerics and they include making the sigs more ~pedantic~ exact.

I hadn't gotten to around to doing integer.rbs, but maybe i should!

sampersand avatar Jul 04 '24 19:07 sampersand