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 block return type #1801

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 core/enumerator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class Enumerator[unchecked out Elem, out Return] < Object
# lazy fashion (see Enumerator#size). It can either be a value or a callable
# object.
#
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> void } -> void
def initialize: (?Integer arg0) { (Enumerator::Yielder arg0) -> Return } -> void

# <!--
# rdoc-file=enumerator.c
Expand Down
11 changes: 11 additions & 0 deletions test/stdlib/Enumerator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,24 @@ def test_with_object
assert_send_type "(String) -> Enumerator[[Integer, String], String]", g, :with_object, ''
assert_send_type "(String) { (Integer, String) -> untyped } -> String", g, :with_object, '' do end
end

def test_each
enum = Enumerator.new { [1,2,3] }
assert_send_type "() { (Integer) -> nil } -> [1,2,3]",
enum, :each do end
end
end

class EnumeratorSingletonTest < Test::Unit::TestCase
include TestHelper

testing "singleton(::Enumerator)"

def test_new
assert_send_type "() { (Enumerator::Yielder) -> 12345 } -> void",
ksss marked this conversation as resolved.
Show resolved Hide resolved
Enumerator, :new do 12345 end
end

def test_produce
assert_send_type(
"(Integer initial) { (Integer) -> Integer } -> Enumerator[Integer, bot]",
Expand Down