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 signature of IO.read and so on #2216

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
6 changes: 3 additions & 3 deletions core/io.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,7 @@ class IO < Object
# potential security vulnerabilities if called with untrusted input; see
# [Command Injection](rdoc-ref:command_injection.rdoc).
#
def self.binread: (String name, ?Integer length, ?Integer offset) -> String
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String

# <!--
# rdoc-file=io.c
Expand Down Expand Up @@ -2343,7 +2343,7 @@ class IO < Object
# IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11
# IO.read('t.tmp') # => "Second line"
#
def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer? copy_length, ?Integer src_offset) -> Integer

# <!--
# rdoc-file=io.c
Expand Down Expand Up @@ -2716,7 +2716,7 @@ class IO < Object
# * [Open Options](rdoc-ref:IO@Open+Options).
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
#
def self.read: (String name, ?Integer length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
def self.read: (String name, ?Integer? length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String

# <!--
# rdoc-file=io.c
Expand Down
4 changes: 4 additions & 0 deletions test/stdlib/IO_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def test_binread
IO, :binread, File.expand_path(__FILE__), 3
assert_send_type "(String, Integer, Integer) -> String",
IO, :binread, File.expand_path(__FILE__), 3, 0
assert_send_type "(String, Integer?, Integer) -> String",
IO, :binread, File.expand_path(__FILE__), nil, 3
end

def test_binwrite
Expand Down Expand Up @@ -88,6 +90,8 @@ def test_copy_stream
IO, :copy_stream, src_name, dst_name, 1
assert_send_type "(String, String, Integer, Integer) -> Integer",
IO, :copy_stream, src_name, dst_name, 1, 0
assert_send_type "(String, String, Integer?, Integer) -> Integer",
IO, :copy_stream, src_name, dst_name, nil, 1

File.open(dst_name, "w") do |dst_io|
assert_send_type "(String, IO) -> Integer",
Expand Down
Loading