From 01ae9928170614706a7a174d3a8370aa10c35a06 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 31 Dec 2024 03:11:26 +0900 Subject: [PATCH 1/2] Add test for IO.binread and .copy_stream in the case of length is nil --- test/stdlib/IO_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/stdlib/IO_test.rb b/test/stdlib/IO_test.rb index a89896eca..3a2f0b8dd 100644 --- a/test/stdlib/IO_test.rb +++ b/test/stdlib/IO_test.rb @@ -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 @@ -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", From 7808e647014bdcf365c98d52243c351a250dfff0 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 31 Dec 2024 03:11:43 +0900 Subject: [PATCH 2/2] Fix signature for IO.binread, .copy_stream and .read --- core/io.rbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/io.rbs b/core/io.rbs index 5b863b327..96f218347 100644 --- a/core/io.rbs +++ b/core/io.rbs @@ -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 #