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

Fix double-splat method #1909

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ GEM
psych (4.0.6)
stringio
public_suffix (6.0.0)
raap (0.8.0)
raap (0.10.0)
rbs (~> 3.0)
timeout (~> 0.4)
racc (1.8.0)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ task :typecheck_test => :compile do
end

task :raap => :compile do
sh %q[cat test/raap.txt | egrep -v '^#|^$' | xargs bundle exec raap]
sh %q[cat test/raap.txt | egrep -v '^#|^$' | xargs bundle exec raap --require bigdecimal/util --library bigdecimal]
end

task :rubocop do
Expand Down
5 changes: 4 additions & 1 deletion core/complex.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ class Complex < Numeric
# Complex('i') ** 2 # => (-1+0i)
# Complex(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
#
def **: (Numeric) -> Complex
def **: (Integer) -> Complex
| (Float) -> Complex
| (Rational) -> Complex
| (Complex) -> Complex

# <!--
# rdoc-file=complex.c
Expand Down
6 changes: 4 additions & 2 deletions core/float.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ class Float < Numeric
# f ** Rational(2, 1) # => 9.8596
# f ** Complex(2, 0) # => (9.8596+0i)
#
def **: (Complex) -> Complex
| (Numeric) -> Float
def **: (Integer) -> Float
| (Float) -> (Float | Complex)
| (Rational) -> (Float | Complex)
| (Complex) -> Complex

# <!--
# rdoc-file=numeric.c
Expand Down
6 changes: 3 additions & 3 deletions core/integer.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ class Integer < Numeric
# 2 ** Rational(3, 1) # => (8/1)
# 2 ** Complex(3, 0) # => (8+0i)
#
def **: (Integer) -> Numeric
| (Float) -> Numeric
| (Rational) -> Numeric
def **: (Integer) -> (Integer | Rational)
| (Float) -> (Float | Complex)
| (Rational) -> (Rational | Float | Complex)
| (Complex) -> Complex

# <!--
Expand Down
6 changes: 4 additions & 2 deletions core/rational.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class Rational < Numeric
# Rational(1, 2) ** 0 #=> (1/1)
# Rational(1, 2) ** 0.0 #=> 1.0
#
def **: (Complex) -> Complex
| (Numeric) -> Numeric
def **: (Integer) -> Rational
| (Float) -> (Float | Complex)
| (Rational) -> (Float | Rational | Complex)
| (Complex) -> (Rational | Complex)

# <!--
# rdoc-file=rational.c
Expand Down
66 changes: 65 additions & 1 deletion stdlib/bigdecimal/0/big_decimal.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@ class BigDecimal < Numeric
#
# Related: BigDecimal#power.
#
def **: (Numeric) -> BigDecimal
def **: (Integer) -> BigDecimal
| (Float) -> (Integer | BigDecimal)
| (Rational) -> (Integer | BigDecimal)
| (BigDecimal) -> BigDecimal

# <!--
# rdoc-file=ext/bigdecimal/bigdecimal.c
Expand Down Expand Up @@ -1497,6 +1500,23 @@ class Integer
#
def -: (BigDecimal) -> BigDecimal
| ...

# <!--
# rdoc-file=numeric.c
# - self ** numeric -> numeric_result
# -->
# Raises `self` to the power of `numeric`:
#
# 2 ** 3 # => 8
# 2 ** -3 # => (1/8)
# -2 ** 3 # => -8
# -2 ** -3 # => (-1/8)
# 2 ** 3.3 # => 9.849155306759329
# 2 ** Rational(3, 1) # => (8/1)
# 2 ** Complex(3, 0) # => (8+0i)
#
def **: (BigDecimal) -> BigDecimal
| ...
end

%a{annotate:rdoc:skip}
Expand Down Expand Up @@ -1581,6 +1601,22 @@ class Float
#
def -: (BigDecimal) -> BigDecimal
| ...

# <!--
# rdoc-file=numeric.c
# - self ** other -> numeric
# -->
# Raises `self` to the power of `other`:
#
# f = 3.14
# f ** 2 # => 9.8596
# f ** -2 # => 0.1014239928597509
# f ** 2.1 # => 11.054834900588839
# f ** Rational(2, 1) # => 9.8596
# f ** Complex(2, 0) # => (9.8596+0i)
#
def **: (BigDecimal) -> BigDecimal
| ...
end

%a{annotate:rdoc:skip}
Expand Down Expand Up @@ -1684,6 +1720,22 @@ class Rational
#
def -: (BigDecimal) -> BigDecimal
| ...

# <!--
# rdoc-file=rational.c
# - rat ** numeric -> numeric
# -->
# Performs exponentiation.
#
# Rational(2) ** Rational(3) #=> (8/1)
# Rational(10) ** -2 #=> (1/100)
# Rational(10) ** -2.0 #=> 0.01
# Rational(-4) ** Rational(1, 2) #=> (0.0+2.0i)
# Rational(1, 2) ** 0 #=> (1/1)
# Rational(1, 2) ** 0.0 #=> 1.0
#
def **: (BigDecimal) -> (Rational | BigDecimal)
| ...
end

%a{annotate:rdoc:skip}
Expand Down Expand Up @@ -1768,6 +1820,18 @@ class Complex
#
def -: (BigDecimal) -> Complex
| ...

# <!--
# rdoc-file=complex.c
# - complex ** numeric -> new_complex
# -->
# Returns `self` raised to power `numeric`:
#
# Complex('i') ** 2 # => (-1+0i)
# Complex(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
#
def **: (BigDecimal) -> Complex
| ...
end

%a{annotate:rdoc:skip}
Expand Down
5 changes: 5 additions & 0 deletions test/raap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@

Set[Integer]
Enumerable[Integer]#to_set
Integer#**
Float#**
Rational#**
Complex#**
BigDecimal#**