Skip to content

Commit f00a84f

Browse files
authored
Merge pull request #2216 from KitaitiMakoto/fix-io-read
Fix signature of IO.read and so on
2 parents 70e340d + 7808e64 commit f00a84f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/io.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,7 @@ class IO < Object
22782278
# potential security vulnerabilities if called with untrusted input; see
22792279
# [Command Injection](rdoc-ref:command_injection.rdoc).
22802280
#
2281-
def self.binread: (String name, ?Integer length, ?Integer offset) -> String
2281+
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
22822282

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

23482348
# <!--
23492349
# rdoc-file=io.c
@@ -2716,7 +2716,7 @@ class IO < Object
27162716
# * [Open Options](rdoc-ref:IO@Open+Options).
27172717
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
27182718
#
2719-
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
2719+
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
27202720

27212721
# <!--
27222722
# rdoc-file=io.c

test/stdlib/IO_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def test_binread
1515
IO, :binread, File.expand_path(__FILE__), 3
1616
assert_send_type "(String, Integer, Integer) -> String",
1717
IO, :binread, File.expand_path(__FILE__), 3, 0
18+
assert_send_type "(String, Integer?, Integer) -> String",
19+
IO, :binread, File.expand_path(__FILE__), nil, 3
1820
end
1921

2022
def test_binwrite
@@ -88,6 +90,8 @@ def test_copy_stream
8890
IO, :copy_stream, src_name, dst_name, 1
8991
assert_send_type "(String, String, Integer, Integer) -> Integer",
9092
IO, :copy_stream, src_name, dst_name, 1, 0
93+
assert_send_type "(String, String, Integer?, Integer) -> Integer",
94+
IO, :copy_stream, src_name, dst_name, nil, 1
9195

9296
File.open(dst_name, "w") do |dst_io|
9397
assert_send_type "(String, IO) -> Integer",

0 commit comments

Comments
 (0)