Skip to content

Commit 12b95e4

Browse files
authored
Merge pull request #2967 from zonuexe/fix/stdlib-signature-corrections
Correct core/stdlib signatures to match Ruby 4.0
2 parents fcc1685 + 518edf2 commit 12b95e4

4 files changed

Lines changed: 72 additions & 18 deletions

File tree

core/io.rbs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,24 @@ class IO < Object
12301230
#
12311231
def ioctl: (Integer integer_cmd, String | Integer argument) -> Integer
12321232

1233+
# <!--
1234+
# rdoc-file=ext/etc/etc.c
1235+
# - pathconf(name) -> Integer
1236+
# -->
1237+
# Returns pathname configuration variable using fpathconf().
1238+
#
1239+
# *name* should be a constant under `Etc` which begins with `PC_`.
1240+
#
1241+
# The return value is an integer or nil. nil means indefinite limit.
1242+
# (fpathconf() returns -1 but errno is not set.)
1243+
#
1244+
# require 'etc'
1245+
# IO.pipe {|r, w|
1246+
# p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096
1247+
# }
1248+
#
1249+
def pathconf: (Integer name) -> Integer?
1250+
12331251
# <!--
12341252
# rdoc-file=io.c
12351253
# - isatty -> true or false

stdlib/digest/0/digest.rbs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ module Digest::Instance
303303
# uninitialized. Do not call this method from outside. Use #digest!() instead,
304304
# which ensures that internal data be reset for security reasons.
305305
#
306-
def finish: () -> self
306+
def finish: () -> String
307307
end
308308

309309
# <!-- rdoc-file=ext/digest/digest.c -->
@@ -319,15 +319,15 @@ class Digest::Class
319319
# Returns the base64 encoded hash value of a given *string*. The return value
320320
# is properly padded with '=' and contains no line feeds.
321321
#
322-
def self.base64digest: (string str) -> String
322+
def self.base64digest: (string str, *untyped args) -> String
323323

324324
# <!--
325325
# rdoc-file=ext/digest/bubblebabble/bubblebabble.c
326326
# - Digest::Class.bubblebabble(string, ...) -> hash_string
327327
# -->
328328
# Returns the BubbleBabble encoded hash value of a given *string*.
329329
#
330-
def self.bubblebabble: (string) -> String
330+
def self.bubblebabble: (string, *untyped) -> String
331331

332332
# <!--
333333
# rdoc-file=ext/digest/digest.c
@@ -338,7 +338,7 @@ class Digest::Class
338338
# any, are passed through to the constructor and the *string* is passed to
339339
# #digest().
340340
#
341-
def self.digest: (string) -> String
341+
def self.digest: (string, *untyped) -> String
342342

343343
# <!--
344344
# rdoc-file=ext/digest/lib/digest.rb
@@ -350,7 +350,7 @@ class Digest::Class
350350
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
351351
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
352352
#
353-
def self.file: (string name) -> instance
353+
def self.file: (string name, *untyped args) -> instance
354354

355355
# <!--
356356
# rdoc-file=ext/digest/digest.c
@@ -359,7 +359,7 @@ class Digest::Class
359359
# Returns the hex-encoded hash value of a given *string*. This is almost
360360
# equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
361361
#
362-
def self.hexdigest: (string) -> String
362+
def self.hexdigest: (string, *untyped) -> String
363363

364364
private
365365

stdlib/etc/0/etc.rbs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ module Etc
295295
# Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152
296296
# Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256
297297
#
298-
def self?.sysconf: (::Integer p1) -> ::Integer
298+
def self?.sysconf: (::Integer p1) -> ::Integer?
299299

300300
# <!--
301301
# rdoc-file=ext/etc/etc.c
@@ -318,7 +318,7 @@ module Etc
318318
# -->
319319
# Returns system temporary directory; typically "/tmp".
320320
#
321-
def self?.systmpdir: () -> ::String
321+
def self?.systmpdir: () -> ::String?
322322

323323
# <!--
324324
# rdoc-file=ext/etc/etc.c
@@ -709,7 +709,8 @@ module Etc
709709
# Etc::Group.collect {|g| g.name}
710710
# Etc::Group.select {|g| !g.mem.empty?}
711711
#
712-
def self.each: () -> untyped
712+
def self.each: () { (::Etc::Group) -> void } -> singleton(::Etc::Group)
713+
| () -> ::Enumerator[::Etc::Group]
713714

714715
def self.inspect: () -> untyped
715716

@@ -817,7 +818,8 @@ module Etc
817818
# Etc::Passwd.collect {|u| u.gecos}
818819
# Etc::Passwd.collect {|u| u.gecos}
819820
#
820-
def self.each: () -> untyped
821+
def self.each: () { (::Etc::Passwd) -> void } -> singleton(::Etc::Passwd)
822+
| () -> ::Enumerator[::Etc::Passwd]
821823

822824
def self.inspect: () -> untyped
823825

@@ -827,10 +829,18 @@ module Etc
827829

828830
def self.new: (*untyped) -> untyped
829831

832+
def age: () -> Integer
833+
834+
def age=: (Integer new_age) -> void
835+
830836
def change: () -> Integer
831837

832838
def change=: (Integer new_change) -> void
833839

840+
def comment: () -> String
841+
842+
def comment=: (String new_comment) -> void
843+
834844
def dir: () -> String
835845

836846
def dir=: (String new_dir) -> void
@@ -855,6 +865,10 @@ module Etc
855865

856866
def passwd=: (String new_passwd) -> void
857867

868+
def quota: () -> Integer
869+
870+
def quota=: (Integer new_quota) -> void
871+
858872
def shell: () -> String
859873

860874
def shell=: (String new_shell) -> void

stdlib/stringio/0/stringio.rbs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ class StringIO
560560
#
561561
# Related: StringIO.new.
562562
#
563-
def self.open: [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
563+
def self.open: (?String string, ?String? mode) -> StringIO
564+
| [U] (?String string, ?String? mode) { (StringIO arg) -> U } -> U
564565

565566
def <<: (untyped arg0) -> self
566567

@@ -970,7 +971,7 @@ class StringIO
970971
# -->
971972
# Raises NotImplementedError.
972973
#
973-
def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer
974+
def fcntl: (*untyped) -> bot
974975

975976
# <!--
976977
# rdoc-file=ext/stringio/stringio.c
@@ -994,7 +995,7 @@ class StringIO
994995
# -->
995996
# Returns 0; for compatibility with IO.
996997
#
997-
def fsync: () -> Integer?
998+
def fsync: () -> Integer
998999

9991000
# <!--
10001001
# rdoc-file=ext/stringio/stringio.c
@@ -1190,7 +1191,7 @@ class StringIO
11901191
# -->
11911192
# Returns `nil`; for compatibility with IO.
11921193
#
1193-
def internal_encoding: () -> Encoding
1194+
def internal_encoding: () -> nil
11941195

11951196
# <!--
11961197
# rdoc-file=ext/stringio/stringio.c
@@ -1207,7 +1208,7 @@ class StringIO
12071208
# strio = StringIO.new(nil, 'w+')
12081209
# strio.external_encoding # => nil
12091210
#
1210-
def external_encoding: () -> Encoding
1211+
def external_encoding: () -> Encoding?
12111212

12121213
# <!--
12131214
# rdoc-file=ext/stringio/stringio.c
@@ -1283,7 +1284,16 @@ class StringIO
12831284
#
12841285
def read: (?int? length, ?string outbuf) -> String?
12851286

1286-
def read_nonblock: (int len, ?string buf) -> String
1287+
# <!--
1288+
# rdoc-file=ext/stringio/stringio.c
1289+
# - pread(maxlen, offset) -> string
1290+
# - pread(maxlen, offset, out_string) -> string
1291+
# -->
1292+
# See IO#pread.
1293+
#
1294+
def pread: (Integer maxlen, Integer offset, ?String outbuf) -> String
1295+
1296+
def read_nonblock: (int len, ?string buf, ?exception: bool) -> String?
12871297

12881298
def readbyte: () -> Integer
12891299

@@ -1358,6 +1368,16 @@ class StringIO
13581368
def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
13591369
| (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
13601370

1371+
# <!--
1372+
# rdoc-file=ext/stringio/stringio.c
1373+
# - strio.set_encoding_by_bom => strio or nil
1374+
# -->
1375+
# Sets the encoding according to the BOM (Byte Order Mark) in the string.
1376+
#
1377+
# Returns `self` if the BOM is found, otherwise +nil.
1378+
#
1379+
def set_encoding_by_bom: () -> Encoding?
1380+
13611381
# <!--
13621382
# rdoc-file=ext/stringio/stringio.c
13631383
# - string -> string
@@ -1429,7 +1449,7 @@ class StringIO
14291449
#
14301450
def sync=: (boolish) -> bool
14311451

1432-
def sysread: (Integer maxlen, String outbuf) -> String
1452+
def sysread: (Integer maxlen, ?String outbuf) -> String
14331453

14341454
def syswrite: (String arg0) -> Integer
14351455

@@ -1472,7 +1492,7 @@ class StringIO
14721492
# Pushes back ("unshifts") a character or integer onto the stream; see
14731493
# [Character IO](rdoc-ref:IO@Character+IO).
14741494
#
1475-
def ungetc: (String arg0) -> nil
1495+
def ungetc: (String | Integer arg0) -> nil
14761496

14771497
# <!--
14781498
# rdoc-file=ext/stringio/stringio.c
@@ -1485,6 +1505,8 @@ class StringIO
14851505
#
14861506
def write: (*_ToS) -> Integer
14871507

1508+
def write_nonblock: (_ToS s, ?exception: bool) -> Integer
1509+
14881510
# This is a deprecated alias for #each_byte.
14891511
#
14901512
def bytes: () { (Integer arg0) -> untyped } -> self

0 commit comments

Comments
 (0)