Skip to content

Commit bc6b2b0

Browse files
committed
Fix method type
1 parent 41ec245 commit bc6b2b0

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

core/range.rbs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,10 @@ class Range[out Elem] < Object
10171017
# ('a'..'e').step { p _1 }
10181018
# # Default step 1; prints: a, b, c, d, e
10191019
#
1020-
def step: (?Numeric | int n) -> Enumerator[Elem, self]
1021-
| (?Numeric | int n) { (Elem element) -> void } -> self
1020+
def step: (?Numeric | int) -> Enumerator[Elem, self]
1021+
| (?Numeric | int) { (Elem element) -> void } -> self
1022+
| (untyped) -> Enumerator[Elem, self]
1023+
| (untyped) { (Elem element) -> void } -> self
10221024

10231025
# <!--
10241026
# rdoc-file=range.c
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
D = Steep::Diagnostic
2+
3+
target :test do
4+
signature "."
5+
check "."
6+
configure_code_diagnostics(D::Ruby.all_error)
7+
end

test/typecheck/range_step/test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# These are valid because step is a number.
2+
3+
(1...3).step(1) { }
4+
("A".."C").step(1) { }
5+
6+
# This works because "A" + "" is valid.
7+
("A".."C").step("") { }
8+
9+
# This doesn't work but the type checker cannot detect it.
10+
("A".."C").step(Exception.new) { }

0 commit comments

Comments
 (0)