Skip to content
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
6 changes: 4 additions & 2 deletions core/array.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,8 @@ class Array[unchecked out E]
#
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
#
def count: () ?{ (E element) -> boolish } -> Integer
def count: () -> Integer
| () { (E element) -> boolish } -> Integer
| (untyped object) -> Integer # where E: RBS::Ops::_Equal

# <!--
Expand Down Expand Up @@ -3734,7 +3735,8 @@ class Array[unchecked out E]
# * Array#sum method may not respect method redefinition of "+" methods such
# as Integer#+.
#
def sum: (?untyped init) ?{ (E e) -> untyped } -> untyped # This would be usable if we had `where E < Complex`, etc
def sum: (?untyped init) -> untyped
| (?untyped init) { (E e) -> untyped } -> untyped # This would be usable if we had `where E < Complex`, etc

# <!--
# rdoc-file=array.c
Expand Down
3 changes: 2 additions & 1 deletion core/hash.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,8 @@ class Hash[unchecked out K, unchecked out V]
# Values](rdoc-ref:Hash@Methods+for+Transforming+Keys+and+Values).
#
def transform_keys!: () -> Enumerator[K, self]
| (hash[K, K] replacements) ?{ (K key) -> K } -> self
| (hash[K, K] replacements) -> self
| (hash[K, K] replacements) { (K key) -> K } -> self
| () { (K key) -> K } -> self

# <!--
Expand Down
7 changes: 7 additions & 0 deletions test/typecheck/block_pass/Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
D = Steep::Diagnostic

target :test do
signature "."
check "."
configure_code_diagnostics(D::Ruby.all_error)
end
11 changes: 11 additions & 0 deletions test/typecheck/block_pass/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Steep cannot check a block-pass argument against an optional block, because the
# expected type becomes a union with `nil` (soutaro/steep#1207). Core signatures
# therefore spell out a blockless overload instead of using `?{ ... }`.

[1, 2, 3].sum(&:to_r)
[1, 2, 3].sum(0r, &:to_r)

[1, 2, 3].count(&:even?)

hash = { 1 => 2 } #: Hash[Integer, Integer]
hash.transform_keys!({ 1 => 3 }, &:itself)
Loading