rbs 3.9.5 → 3.10.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +74 -0
  3. data/.clangd +2 -0
  4. data/.github/workflows/c-check.yml +54 -0
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/ruby.yml +34 -19
  7. data/.github/workflows/typecheck.yml +1 -1
  8. data/.github/workflows/windows.yml +1 -1
  9. data/.gitignore +4 -0
  10. data/README.md +38 -1
  11. data/Rakefile +152 -23
  12. data/config.yml +190 -62
  13. data/core/array.rbs +44 -43
  14. data/core/dir.rbs +2 -2
  15. data/core/encoding.rbs +3 -2
  16. data/core/enumerable.rbs +89 -2
  17. data/core/errno.rbs +8 -0
  18. data/core/errors.rbs +28 -1
  19. data/core/exception.rbs +2 -2
  20. data/core/fiber.rbs +3 -3
  21. data/core/file.rbs +26 -11
  22. data/core/float.rbs +1 -1
  23. data/core/gc.rbs +422 -281
  24. data/core/hash.rbs +1024 -727
  25. data/core/io/wait.rbs +11 -33
  26. data/core/io.rbs +6 -4
  27. data/core/kernel.rbs +49 -43
  28. data/core/marshal.rbs +1 -1
  29. data/core/match_data.rbs +1 -1
  30. data/core/math.rbs +42 -3
  31. data/core/method.rbs +14 -6
  32. data/core/module.rbs +71 -11
  33. data/core/nil_class.rbs +3 -3
  34. data/core/numeric.rbs +8 -8
  35. data/core/object.rbs +3 -3
  36. data/core/object_space.rbs +13 -0
  37. data/{stdlib/pathname/0 → core}/pathname.rbs +253 -352
  38. data/core/proc.rbs +15 -8
  39. data/core/process.rbs +2 -2
  40. data/core/ractor.rbs +278 -437
  41. data/core/range.rbs +6 -7
  42. data/core/rbs/unnamed/argf.rbs +1 -1
  43. data/core/rbs/unnamed/env_class.rbs +1 -1
  44. data/core/rbs/unnamed/random.rbs +4 -2
  45. data/core/regexp.rbs +22 -17
  46. data/core/ruby_vm.rbs +6 -4
  47. data/core/rubygems/errors.rbs +3 -70
  48. data/core/rubygems/rubygems.rbs +11 -79
  49. data/core/set.rbs +439 -332
  50. data/core/string.rbs +2897 -1117
  51. data/core/struct.rbs +1 -1
  52. data/core/symbol.rbs +4 -4
  53. data/core/thread.rbs +83 -20
  54. data/core/time.rbs +35 -9
  55. data/core/unbound_method.rbs +14 -6
  56. data/docs/aliases.md +79 -0
  57. data/docs/collection.md +2 -2
  58. data/docs/gem.md +0 -1
  59. data/docs/sigs.md +3 -3
  60. data/ext/rbs_extension/ast_translation.c +1016 -0
  61. data/ext/rbs_extension/ast_translation.h +37 -0
  62. data/ext/rbs_extension/class_constants.c +157 -0
  63. data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
  64. data/ext/rbs_extension/compat.h +10 -0
  65. data/ext/rbs_extension/extconf.rb +25 -1
  66. data/ext/rbs_extension/legacy_location.c +317 -0
  67. data/ext/rbs_extension/legacy_location.h +45 -0
  68. data/ext/rbs_extension/main.c +365 -14
  69. data/ext/rbs_extension/rbs_extension.h +6 -21
  70. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  71. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  72. data/include/rbs/ast.h +687 -0
  73. data/include/rbs/defines.h +86 -0
  74. data/include/rbs/lexer.h +199 -0
  75. data/include/rbs/location.h +59 -0
  76. data/include/rbs/parser.h +135 -0
  77. data/include/rbs/string.h +49 -0
  78. data/include/rbs/util/rbs_allocator.h +59 -0
  79. data/include/rbs/util/rbs_assert.h +20 -0
  80. data/include/rbs/util/rbs_buffer.h +83 -0
  81. data/include/rbs/util/rbs_constant_pool.h +6 -67
  82. data/include/rbs/util/rbs_encoding.h +282 -0
  83. data/include/rbs/util/rbs_unescape.h +23 -0
  84. data/include/rbs.h +1 -2
  85. data/lib/rbs/annotate/formatter.rb +3 -13
  86. data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
  87. data/lib/rbs/annotate/rdoc_source.rb +1 -1
  88. data/lib/rbs/cli/validate.rb +2 -2
  89. data/lib/rbs/cli.rb +1 -1
  90. data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
  91. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
  92. data/lib/rbs/environment.rb +64 -59
  93. data/lib/rbs/environment_loader.rb +1 -1
  94. data/lib/rbs/errors.rb +1 -1
  95. data/lib/rbs/parser_aux.rb +5 -0
  96. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  97. data/lib/rbs/resolver/type_name_resolver.rb +124 -38
  98. data/lib/rbs/test/type_check.rb +13 -0
  99. data/lib/rbs/types.rb +3 -1
  100. data/lib/rbs/version.rb +1 -1
  101. data/lib/rbs.rb +1 -1
  102. data/lib/rdoc/discover.rb +1 -1
  103. data/lib/rdoc_plugin/parser.rb +3 -3
  104. data/sig/annotate/formatter.rbs +2 -2
  105. data/sig/annotate/rdoc_annotater.rbs +1 -1
  106. data/sig/environment.rbs +57 -6
  107. data/sig/manifest.yaml +0 -1
  108. data/sig/parser.rbs +20 -0
  109. data/sig/resolver/type_name_resolver.rbs +38 -7
  110. data/sig/types.rbs +4 -1
  111. data/src/ast.c +1256 -0
  112. data/src/lexer.c +2956 -0
  113. data/src/lexer.re +147 -0
  114. data/src/lexstate.c +205 -0
  115. data/src/location.c +71 -0
  116. data/src/parser.c +3495 -0
  117. data/src/string.c +90 -0
  118. data/src/util/rbs_allocator.c +152 -0
  119. data/src/util/rbs_assert.c +21 -0
  120. data/src/util/rbs_buffer.c +54 -0
  121. data/src/util/rbs_constant_pool.c +16 -86
  122. data/src/util/rbs_encoding.c +21308 -0
  123. data/src/util/rbs_unescape.c +131 -0
  124. data/stdlib/cgi/0/core.rbs +2 -396
  125. data/stdlib/cgi/0/manifest.yaml +1 -0
  126. data/stdlib/cgi-escape/0/escape.rbs +153 -0
  127. data/stdlib/coverage/0/coverage.rbs +3 -1
  128. data/stdlib/delegate/0/delegator.rbs +10 -7
  129. data/stdlib/erb/0/erb.rbs +737 -347
  130. data/stdlib/fileutils/0/fileutils.rbs +18 -13
  131. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  132. data/stdlib/json/0/json.rbs +67 -48
  133. data/stdlib/net-http/0/net-http.rbs +3 -0
  134. data/stdlib/objspace/0/objspace.rbs +8 -3
  135. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  136. data/stdlib/openssl/0/openssl.rbs +182 -149
  137. data/stdlib/optparse/0/optparse.rbs +3 -3
  138. data/stdlib/rdoc/0/code_object.rbs +2 -2
  139. data/stdlib/rdoc/0/comment.rbs +2 -0
  140. data/stdlib/rdoc/0/options.rbs +76 -0
  141. data/stdlib/rdoc/0/rdoc.rbs +7 -5
  142. data/stdlib/rdoc/0/store.rbs +1 -1
  143. data/stdlib/resolv/0/resolv.rbs +25 -68
  144. data/stdlib/ripper/0/ripper.rbs +5 -2
  145. data/stdlib/singleton/0/singleton.rbs +3 -0
  146. data/stdlib/socket/0/socket.rbs +13 -1
  147. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  148. data/stdlib/stringio/0/stringio.rbs +412 -80
  149. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  150. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  151. data/stdlib/tsort/0/cyclic.rbs +3 -0
  152. data/stdlib/uri/0/common.rbs +11 -2
  153. data/stdlib/uri/0/file.rbs +1 -1
  154. data/stdlib/uri/0/generic.rbs +16 -15
  155. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  156. data/stdlib/zlib/0/zstream.rbs +1 -0
  157. metadata +41 -18
  158. data/ext/rbs_extension/lexer.c +0 -2728
  159. data/ext/rbs_extension/lexer.h +0 -179
  160. data/ext/rbs_extension/lexer.re +0 -147
  161. data/ext/rbs_extension/lexstate.c +0 -175
  162. data/ext/rbs_extension/location.c +0 -325
  163. data/ext/rbs_extension/location.h +0 -85
  164. data/ext/rbs_extension/parser.c +0 -2982
  165. data/ext/rbs_extension/parser.h +0 -18
  166. data/ext/rbs_extension/parserstate.c +0 -411
  167. data/ext/rbs_extension/parserstate.h +0 -163
  168. data/ext/rbs_extension/unescape.c +0 -32
  169. data/include/rbs/ruby_objs.h +0 -72
  170. data/src/constants.c +0 -153
  171. data/src/ruby_objs.c +0 -799
data/core/io/wait.rbs CHANGED
@@ -1,30 +1,9 @@
1
1
  %a{annotate:rdoc:skip}
2
2
  class IO
3
3
  # <!--
4
- # rdoc-file=ext/io/wait/wait.c
5
- # - io.nread -> int
6
- # -->
7
- # Returns number of bytes that can be read without blocking. Returns zero if no
8
- # information available.
9
- #
10
- # You must require 'io/wait' to use this method.
11
- #
12
- def nread: () -> Integer
13
-
14
- # <!--
15
- # rdoc-file=ext/io/wait/wait.c
16
- # - io.ready? -> truthy or falsy
17
- # -->
18
- # Returns a truthy value if input available without blocking, or a falsy value.
19
- #
20
- # You must require 'io/wait' to use this method.
21
- #
22
- def ready?: () -> boolish
23
-
24
- # <!--
25
- # rdoc-file=ext/io/wait/wait.c
4
+ # rdoc-file=io.c
26
5
  # - io.wait(events, timeout) -> event mask, false or nil
27
- # - io.wait(timeout = nil, mode = :read) -> self, true, or false
6
+ # - io.wait(*event_symbols[, timeout]) -> self, true, or false
28
7
  # -->
29
8
  # Waits until the IO becomes ready for the specified events and returns the
30
9
  # subset of events that become ready, or a falsy value when times out.
@@ -32,11 +11,14 @@ class IO
32
11
  # The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
33
12
  # `IO::PRIORITY`.
34
13
  #
35
- # Returns a truthy value immediately when buffered data is available.
36
- #
37
- # Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`.
14
+ # Returns an event mask (truthy value) immediately when buffered data is
15
+ # available.
38
16
  #
39
- # You must require 'io/wait' to use this method.
17
+ # The second form: if one or more event symbols (`:read`, `:write`, or
18
+ # `:read_write`) are passed, the event mask is the bit OR of the bitmask
19
+ # corresponding to those symbols. In this form, `timeout` is optional, the
20
+ # order of the arguments is arbitrary, and returns `io` if any of the events is
21
+ # ready.
40
22
  #
41
23
  def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
42
24
  | (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
@@ -44,7 +26,7 @@ class IO
44
26
  type wait_mode = :read | :r | :readable | :write | :w | :writable | :read_write | :rw | :readable_writable
45
27
 
46
28
  # <!--
47
- # rdoc-file=ext/io/wait/wait.c
29
+ # rdoc-file=io.c
48
30
  # - io.wait_readable -> truthy or falsy
49
31
  # - io.wait_readable(timeout) -> truthy or falsy
50
32
  # -->
@@ -52,19 +34,15 @@ class IO
52
34
  # times out. Returns a truthy value immediately when buffered data is
53
35
  # available.
54
36
  #
55
- # You must require 'io/wait' to use this method.
56
- #
57
37
  def wait_readable: (?Time::_Timeout? timeout) -> boolish
58
38
 
59
39
  # <!--
60
- # rdoc-file=ext/io/wait/wait.c
40
+ # rdoc-file=io.c
61
41
  # - io.wait_writable -> truthy or falsy
62
42
  # - io.wait_writable(timeout) -> truthy or falsy
63
43
  # -->
64
44
  # Waits until IO is writable and returns a truthy value or a falsy value when
65
45
  # times out.
66
46
  #
67
- # You must require 'io/wait' to use this method.
68
- #
69
47
  def wait_writable: (?Time::_Timeout? timeout) -> boolish
70
48
  end
data/core/io.rbs CHANGED
@@ -2361,8 +2361,9 @@ class IO < Object
2361
2361
  # closed (eventually) to avoid resource leaks.
2362
2362
  #
2363
2363
  # If a block is given, the stream is passed to the block (again, open for
2364
- # reading, writing, or both); when the block exits, the stream is closed, and
2365
- # the block's value is assigned to global variable `$?` and returned.
2364
+ # reading, writing, or both); when the block exits, the stream is closed, the
2365
+ # block's value is returned, and the global variable `$?` is set to the child's
2366
+ # exit status.
2366
2367
  #
2367
2368
  # Optional argument `mode` may be any valid IO mode. See [Access
2368
2369
  # Modes](rdoc-ref:File@Access+Modes).
@@ -2391,7 +2392,7 @@ class IO < Object
2391
2392
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2392
2393
  # * Options for Kernel#spawn.
2393
2394
  #
2394
- # **Forked \Process**
2395
+ # **Forked Process**
2395
2396
  #
2396
2397
  # When argument `cmd` is the 1-character string `'-'`, causes the process to
2397
2398
  # fork:
@@ -2785,7 +2786,8 @@ class IO < Object
2785
2786
  # IO objects.
2786
2787
  #
2787
2788
  # Argument `timeout` is a numeric value (such as integer or float) timeout
2788
- # interval in seconds.
2789
+ # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
2790
+ # and `Float::INFINITY` means no timeout.
2789
2791
  #
2790
2792
  # The method monitors the IO objects given in all three arrays, waiting for some
2791
2793
  # to be ready; returns a 3-element array whose elements are:
data/core/kernel.rbs CHANGED
@@ -80,7 +80,7 @@
80
80
  # * #print: Prints the given objects to standard output without a newline.
81
81
  # * #printf: Prints the string resulting from applying the given format string
82
82
  # to any additional arguments.
83
- # * #putc: Equivalent to <tt.$stdout.putc(object)</tt> for the given object.
83
+ # * #putc: Equivalent to `$stdout.putc(object)` for the given object.
84
84
  # * #puts: Equivalent to `$stdout.puts(*objects)` for the given objects.
85
85
  # * #readline: Similar to #gets, but raises an exception at the end of file.
86
86
  # * #readlines: Returns an array of the remaining lines from the current
@@ -725,7 +725,7 @@ module Kernel : BasicObject
725
725
  # $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n"
726
726
  # $ `echo oops && exit 99` # => "oops\n"
727
727
  # $ $? # => #<Process::Status: pid 17088 exit 99>
728
- # $ $?.status # => 99>
728
+ # $ $?.exitstatus # => 99
729
729
  #
730
730
  # The built-in syntax `%x{...}` uses this method.
731
731
  #
@@ -777,6 +777,8 @@ module Kernel : BasicObject
777
777
  # If *const* is defined as autoload, the file name to be loaded is replaced with
778
778
  # *filename*. If *const* is defined but not as autoload, does nothing.
779
779
  #
780
+ # Files that are currently being loaded must not be registered for autoload.
781
+ #
780
782
  def self?.autoload: (interned _module, String filename) -> NilClass
781
783
 
782
784
  # <!--
@@ -1218,6 +1220,7 @@ module Kernel : BasicObject
1218
1220
  # loop do
1219
1221
  # print "Input: "
1220
1222
  # line = gets
1223
+ # # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
1221
1224
  # break if !line or line =~ /^q/i
1222
1225
  # # ...
1223
1226
  # end
@@ -1463,7 +1466,9 @@ module Kernel : BasicObject
1463
1466
  # Kernel.srand may be used to ensure that sequences of random numbers are
1464
1467
  # reproducible between different runs of a program.
1465
1468
  #
1466
- # See also Random.rand.
1469
+ # Related: Random.rand.
1470
+ # rand(100.0) # => 64 (Integer because max.to_i is 100)
1471
+ # Random.rand(100.0) # => 30.315320967824523
1467
1472
  #
1468
1473
  def self?.rand: (?0) -> Float
1469
1474
  | (int arg0) -> Integer
@@ -1585,7 +1590,8 @@ module Kernel : BasicObject
1585
1590
  # IO objects.
1586
1591
  #
1587
1592
  # Argument `timeout` is a numeric value (such as integer or float) timeout
1588
- # interval in seconds.
1593
+ # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
1594
+ # and `Float::INFINITY` means no timeout.
1589
1595
  #
1590
1596
  # The method monitors the IO objects given in all three arrays, waiting for some
1591
1597
  # to be ready; returns a 3-element array whose elements are:
@@ -1773,58 +1779,58 @@ module Kernel : BasicObject
1773
1779
  # * Each of these tests operates only on the entity at `path0`,
1774
1780
  # and returns `true` or `false`;
1775
1781
  # for a non-existent entity, returns `false` (does not raise exception):
1776
- # Character |Test
1777
- # ------------|-------------------------------------------------------------------------
1778
- # <tt>'b'</tt>|Whether the entity is a block device.
1779
- # <tt>'c'</tt>|Whether the entity is a character device.
1780
- # <tt>'d'</tt>|Whether the entity is a directory.
1781
- # <tt>'e'</tt>|Whether the entity is an existing entity.
1782
- # <tt>'f'</tt>|Whether the entity is an existing regular file.
1783
- # <tt>'g'</tt>|Whether the entity's setgid bit is set.
1784
- # <tt>'G'</tt>|Whether the entity's group ownership is equal to the caller's.
1785
- # <tt>'k'</tt>|Whether the entity's sticky bit is set.
1786
- # <tt>'l'</tt>|Whether the entity is a symbolic link.
1787
- # <tt>'o'</tt>|Whether the entity is owned by the caller's effective uid.
1788
- # <tt>'O'</tt>|Like <tt>'o'</tt>, but uses the real uid (not the effective uid).
1789
- # <tt>'p'</tt>|Whether the entity is a FIFO device (named pipe).
1790
- # <tt>'r'</tt>|Whether the entity is readable by the caller's effective uid/gid.
1791
- # <tt>'R'</tt>|Like <tt>'r'</tt>, but uses the real uid/gid (not the effective uid/gid).
1792
- # <tt>'S'</tt>|Whether the entity is a socket.
1793
- # <tt>'u'</tt>|Whether the entity's setuid bit is set.
1794
- # <tt>'w'</tt>|Whether the entity is writable by the caller's effective uid/gid.
1795
- # <tt>'W'</tt>|Like <tt>'w'</tt>, but uses the real uid/gid (not the effective uid/gid).
1796
- # <tt>'x'</tt>|Whether the entity is executable by the caller's effective uid/gid.
1797
- # <tt>'X'</tt>|Like <tt>'x'</tt>, but uses the real uid/gid (not the effective uid/git).
1798
- # <tt>'z'</tt>|Whether the entity exists and is of length zero.
1782
+ # Character|Test
1783
+ # ---------|-------------------------------------------------------------------
1784
+ # `'b'` |Whether the entity is a block device.
1785
+ # `'c'` |Whether the entity is a character device.
1786
+ # `'d'` |Whether the entity is a directory.
1787
+ # `'e'` |Whether the entity is an existing entity.
1788
+ # `'f'` |Whether the entity is an existing regular file.
1789
+ # `'g'` |Whether the entity's setgid bit is set.
1790
+ # `'G'` |Whether the entity's group ownership is equal to the caller's.
1791
+ # `'k'` |Whether the entity's sticky bit is set.
1792
+ # `'l'` |Whether the entity is a symbolic link.
1793
+ # `'o'` |Whether the entity is owned by the caller's effective uid.
1794
+ # `'O'` |Like `'o'`, but uses the real uid (not the effective uid).
1795
+ # `'p'` |Whether the entity is a FIFO device (named pipe).
1796
+ # `'r'` |Whether the entity is readable by the caller's effective uid/gid.
1797
+ # `'R'` |Like `'r'`, but uses the real uid/gid (not the effective uid/gid).
1798
+ # `'S'` |Whether the entity is a socket.
1799
+ # `'u'` |Whether the entity's setuid bit is set.
1800
+ # `'w'` |Whether the entity is writable by the caller's effective uid/gid.
1801
+ # `'W'` |Like `'w'`, but uses the real uid/gid (not the effective uid/gid).
1802
+ # `'x'` |Whether the entity is executable by the caller's effective uid/gid.
1803
+ # `'X'` |Like `'x'`, but uses the real uid/gid (not the effective uid/git).
1804
+ # `'z'` |Whether the entity exists and is of length zero.
1799
1805
  # * This test operates only on the entity at `path0`,
1800
1806
  # and returns an integer size or `nil`:
1801
- # Character |Test
1802
- # ------------|--------------------------------------------------------------------------------------------
1803
- # <tt>'s'</tt>|Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise.
1807
+ # Character|Test
1808
+ # ---------|--------------------------------------------------------------------------------------------
1809
+ # `'s'` |Returns positive integer size if the entity exists and has non-zero length, `nil` otherwise.
1804
1810
  # * Each of these tests operates only on the entity at `path0`,
1805
1811
  # and returns a Time object;
1806
1812
  # raises an exception if the entity does not exist:
1807
- # Character |Test
1808
- # ------------|--------------------------------------
1809
- # <tt>'A'</tt>|Last access time for the entity.
1810
- # <tt>'C'</tt>|Last change time for the entity.
1811
- # <tt>'M'</tt>|Last modification time for the entity.
1813
+ # Character|Test
1814
+ # ---------|--------------------------------------
1815
+ # `'A'` |Last access time for the entity.
1816
+ # `'C'` |Last change time for the entity.
1817
+ # `'M'` |Last modification time for the entity.
1812
1818
  # * Each of these tests operates on the modification time (`mtime`)
1813
1819
  # of each of the entities at `path0` and `path1`,
1814
1820
  # and returns a `true` or `false`;
1815
1821
  # returns `false` if either entity does not exist:
1816
- # Character |Test
1817
- # ------------|---------------------------------------------------------------
1818
- # <tt>'<'</tt>|Whether the `mtime` at `path0` is less than that at `path1`.
1819
- # <tt>'='</tt>|Whether the `mtime` at `path0` is equal to that at `path1`.
1820
- # <tt>'>'</tt>|Whether the `mtime` at `path0` is greater than that at `path1`.
1822
+ # Character|Test
1823
+ # ---------|---------------------------------------------------------------
1824
+ # `'<'` |Whether the `mtime` at `path0` is less than that at `path1`.
1825
+ # `'='` |Whether the `mtime` at `path0` is equal to that at `path1`.
1826
+ # `'>'` |Whether the `mtime` at `path0` is greater than that at `path1`.
1821
1827
  # * This test operates on the content of each of the entities at `path0` and
1822
1828
  # `path1`,
1823
1829
  # and returns a `true` or `false`;
1824
1830
  # returns `false` if either entity does not exist:
1825
- # Character |Test
1826
- # ------------|---------------------------------------------
1827
- # <tt>'-'</tt>|Whether the entities exist and are identical.
1831
+ # Character|Test
1832
+ # ---------|---------------------------------------------
1833
+ # `'-'` |Whether the entities exist and are identical.
1828
1834
  #
1829
1835
  def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
1830
1836
 
data/core/marshal.rbs CHANGED
@@ -147,7 +147,7 @@ module Marshal
147
147
  # * anonymous Class/Module.
148
148
  # * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket
149
149
  # and so on)
150
- # * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread,
150
+ # * an instance of MatchData, Method, UnboundMethod, Proc, Thread,
151
151
  # ThreadGroup, Continuation
152
152
  # * objects which define singleton methods
153
153
  #
data/core/match_data.rbs CHANGED
@@ -41,7 +41,7 @@
41
41
  # * `$'` is Regexp.last_match`.post_match`;
42
42
  # * `$+` is Regexp.last_match`[ -1 ]` (the last capture).
43
43
  #
44
- # See also "Special global variables" section in Regexp documentation.
44
+ # See also Regexp@Global+Variables.
45
45
  #
46
46
  class MatchData
47
47
  type capture = String | Symbol | int
data/core/math.rbs CHANGED
@@ -410,6 +410,27 @@ module Math
410
410
  #
411
411
  def self.exp: (double x) -> Float
412
412
 
413
+ # <!--
414
+ # rdoc-file=math.c
415
+ # - Math.expm1(x) -> float
416
+ # -->
417
+ # Returns "exp(x) - 1", `e` raised to the `x` power, minus 1.
418
+ #
419
+ # * Domain: `[-INFINITY, INFINITY]`.
420
+ # * Range: `[-1.0, INFINITY]`.
421
+ #
422
+ # Examples:
423
+ #
424
+ # expm1(-INFINITY) # => 0.0
425
+ # expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1
426
+ # expm1(0.0) # => 0.0
427
+ # expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1
428
+ # expm1(1.0) # => 1.718281828459045 # E - 1
429
+ # expm1(2.0) # => 6.38905609893065 # E**2 - 1
430
+ # expm1(INFINITY) # => Infinity
431
+ #
432
+ def self.expm1: (double x) -> Float
433
+
413
434
  # <!--
414
435
  # rdoc-file=math.c
415
436
  # - Math.frexp(x) -> [fraction, exponent]
@@ -525,9 +546,8 @@ module Math
525
546
  #
526
547
  # [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
527
548
  #
528
- # See [logarithmic gamma
529
- # function](https://en.wikipedia.org/wiki/Gamma_function#The_log-gamma_function)
530
- # .
549
+ # See [log gamma
550
+ # function](https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function).
531
551
  #
532
552
  # * Domain: `(-INFINITY, INFINITY]`.
533
553
  # * Range of first element: `(-INFINITY, INFINITY]`.
@@ -603,6 +623,25 @@ module Math
603
623
  #
604
624
  def self.log10: (double x) -> Float
605
625
 
626
+ # <!--
627
+ # rdoc-file=math.c
628
+ # - Math.log1p(x) -> float
629
+ # -->
630
+ # Returns "log(x + 1)", the base E
631
+ # [logarithm](https://en.wikipedia.org/wiki/Logarithm) of (`x` + 1).
632
+ #
633
+ # * Domain: `[-1, INFINITY]`.
634
+ # * Range: `[-INFINITY, INFINITY]`.
635
+ #
636
+ # Examples:
637
+ #
638
+ # log1p(-1.0) # => -Infinity
639
+ # log1p(0.0) # => 0.0
640
+ # log1p(E - 1) # => 1.0
641
+ # log1p(INFINITY) # => Infinity
642
+ #
643
+ def self.log1p: (double x) -> Float
644
+
606
645
  # <!--
607
646
  # rdoc-file=math.c
608
647
  # - Math.log2(x) -> float
data/core/method.rbs CHANGED
@@ -1,5 +1,5 @@
1
1
  # <!-- rdoc-file=proc.c -->
2
- # Method objects are created by Object#method, and are associated with a
2
+ # `Method` objects are created by Object#method, and are associated with a
3
3
  # particular object (not just with a class). They may be used to invoke the
4
4
  # method within the object, and as a block associated with an iterator. They
5
5
  # may also be unbound from one object (creating an UnboundMethod) and bound to
@@ -359,10 +359,18 @@ class Method
359
359
 
360
360
  # <!--
361
361
  # rdoc-file=proc.c
362
- # - meth.source_location -> [String, Integer]
362
+ # - meth.source_location -> [String, Integer, Integer, Integer, Integer]
363
363
  # -->
364
- # Returns the Ruby source filename and line number containing this method or nil
365
- # if this method was not defined in Ruby (i.e. native).
364
+ # Returns the location where the method was defined. The returned Array
365
+ # contains:
366
+ # (1) the Ruby source filename
367
+ # (2) the line number where the definition starts
368
+ # (3) the column number where the definition starts
369
+ # (4) the line number where the definition ends
370
+ # (5) the column number where the definitions ends
371
+ #
372
+ # This method will return `nil` if the method was not defined in Ruby (i.e.
373
+ # native).
366
374
  #
367
375
  def source_location: () -> [String, Integer]?
368
376
 
@@ -370,8 +378,8 @@ class Method
370
378
  # rdoc-file=proc.c
371
379
  # - meth.super_method -> method
372
380
  # -->
373
- # Returns a Method of superclass which would be called when super is used or nil
374
- # if there is no method on superclass.
381
+ # Returns a `Method` of superclass which would be called when super is used or
382
+ # nil if there is no method on superclass.
375
383
  #
376
384
  def super_method: () -> Method?
377
385
 
data/core/module.rbs CHANGED
@@ -328,6 +328,8 @@ class Module < Object
328
328
  # replaced with *filename*. If *const* is defined but not as autoload, does
329
329
  # nothing.
330
330
  #
331
+ # Files that are currently being loaded must not be registered for autoload.
332
+ #
331
333
  def autoload: (interned _module, String filename) -> NilClass
332
334
 
333
335
  # <!--
@@ -487,6 +489,31 @@ class Module < Object
487
489
  #
488
490
  # Added :FOO
489
491
  #
492
+ # If we define a class using the `class` keyword, `const_added` runs before
493
+ # `inherited`:
494
+ #
495
+ # module M
496
+ # def self.const_added(const_name)
497
+ # super
498
+ # p :const_added
499
+ # end
500
+ #
501
+ # parent = Class.new do
502
+ # def self.inherited(subclass)
503
+ # super
504
+ # p :inherited
505
+ # end
506
+ # end
507
+ #
508
+ # class Child < parent
509
+ # end
510
+ # end
511
+ #
512
+ # *produces:*
513
+ #
514
+ # :const_added
515
+ # :inherited
516
+ #
490
517
  def const_added: (Symbol) -> void
491
518
 
492
519
  # <!--
@@ -1321,19 +1348,52 @@ class Module < Object
1321
1348
  # - protected(method_name, method_name, ...) -> array
1322
1349
  # - protected(array) -> array
1323
1350
  # -->
1324
- # With no arguments, sets the default visibility for subsequently defined
1325
- # methods to protected. With arguments, sets the named methods to have protected
1326
- # visibility. String arguments are converted to symbols. An Array of Symbols
1327
- # and/or Strings is also accepted. If a single argument is passed, it is
1328
- # returned. If no argument is passed, nil is returned. If multiple arguments are
1329
- # passed, the arguments are returned as an array.
1351
+ # Sets the visibility of a section or of a list of method names as protected.
1352
+ # Accepts no arguments, a splat of method names (symbols or strings) or an array
1353
+ # of method names. Returns the arguments that it received.
1354
+ #
1355
+ # ## Important difference between protected in other languages
1356
+ #
1357
+ # Protected methods in Ruby are different from other languages such as Java,
1358
+ # where methods are marked as protected to give access to subclasses. In Ruby,
1359
+ # subclasses **already have access to all methods defined in the parent class**,
1360
+ # even private ones.
1361
+ #
1362
+ # Marking a method as protected allows **different objects of the same class**
1363
+ # to call it.
1364
+ #
1365
+ # One use case is for comparison methods, such as `==`, if we want to expose a
1366
+ # method for comparison between objects of the same class without making the
1367
+ # method public to objects of other classes.
1368
+ #
1369
+ # ## Performance considerations
1370
+ #
1371
+ # Protected methods are slower than others because they can't use inline cache.
1372
+ #
1373
+ # ## Example
1374
+ #
1375
+ # class Account
1376
+ # # Mark balance as protected, so that we can compare between accounts
1377
+ # # without making it public.
1378
+ # attr_reader :balance
1379
+ # protected :balance
1380
+ #
1381
+ # def initialize(balance)
1382
+ # @balance = balance
1383
+ # end
1384
+ #
1385
+ # def >(other)
1386
+ # # The invocation to `other.balance` is allowed because `other` is a
1387
+ # # different object of the same class (Account).
1388
+ # balance > other.balance
1389
+ # end
1390
+ # end
1330
1391
  #
1331
- # If a method has protected visibility, it is callable only where `self` of the
1332
- # context is the same as the method. (method definition or instance_eval). This
1333
- # behavior is different from Java's protected method. Usually `private` should
1334
- # be used.
1392
+ # account1 = Account.new(100)
1393
+ # account2 = Account.new(50)
1335
1394
  #
1336
- # Note that a protected method is slow because it can't use inline cache.
1395
+ # account1 > account2 # => true (works)
1396
+ # account1.balance # => NoMethodError (fails because balance is not public)
1337
1397
  #
1338
1398
  # To show a private method on RDoc, use `:doc:` instead of this.
1339
1399
  #
data/core/nil_class.rbs CHANGED
@@ -112,7 +112,7 @@ class NilClass
112
112
  def nil?: () -> true
113
113
 
114
114
  # <!--
115
- # rdoc-file=rational.c
115
+ # rdoc-file=nilclass.rb
116
116
  # - rationalize(eps = nil) -> (0/1)
117
117
  # -->
118
118
  # Returns zero as a Rational:
@@ -134,7 +134,7 @@ class NilClass
134
134
  def to_a: () -> []
135
135
 
136
136
  # <!--
137
- # rdoc-file=complex.c
137
+ # rdoc-file=nilclass.rb
138
138
  # - to_c -> (0+0i)
139
139
  # -->
140
140
  # Returns zero as a Complex:
@@ -174,7 +174,7 @@ class NilClass
174
174
  def to_i: () -> 0
175
175
 
176
176
  # <!--
177
- # rdoc-file=rational.c
177
+ # rdoc-file=nilclass.rb
178
178
  # - to_r -> (0/1)
179
179
  # -->
180
180
  # Returns zero as a Rational:
data/core/numeric.rbs CHANGED
@@ -530,17 +530,17 @@ class Numeric
530
530
  # rdoc-file=numeric.c
531
531
  # - nonzero? -> self or nil
532
532
  # -->
533
- # Returns +self+ if +self+ is not a zero value, +nil+ otherwise;
534
- # uses method <tt>zero?</tt> for the evaluation.
533
+ # Returns `self` if `self` is not a zero value, `nil` otherwise; uses method
534
+ # `zero?` for the evaluation.
535
535
  #
536
- # The returned +self+ allows the method to be chained:
536
+ # The returned `self` allows the method to be chained:
537
537
  #
538
- # a = %w[z Bb bB bb BB a aA Aa AA A]
539
- # a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
540
- # # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
538
+ # a = %w[z Bb bB bb BB a aA Aa AA A]
539
+ # a.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b }
540
+ # # => ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"]
541
541
  #
542
- # Of the Core and Standard Library classes,
543
- # Integer, Float, Rational, and Complex use this implementation.
542
+ # Of the Core and Standard Library classes, Integer, Float, Rational, and
543
+ # Complex use this implementation.
544
544
  #
545
545
  # Related: #zero?
546
546
  #
data/core/object.rbs CHANGED
@@ -40,7 +40,7 @@
40
40
  # * #instance_of?: Returns whether `self` is an instance of the given class.
41
41
  # * #instance_variable_defined?: Returns whether the given instance variable
42
42
  # is defined in `self`.
43
- # * #method: Returns the Method object for the given method in `self`.
43
+ # * #method: Returns the `Method` object for the given method in `self`.
44
44
  # * #methods: Returns an array of symbol names of public and protected methods
45
45
  # in `self`.
46
46
  # * #nil?: Returns `false`. (Only `nil` responds `true` to method `nil?`.)
@@ -50,13 +50,13 @@
50
50
  # methods in `self`.
51
51
  # * #protected_methods: Returns an array of the symbol names of the protected
52
52
  # methods in `self`.
53
- # * #public_method: Returns the Method object for the given public method in
53
+ # * #public_method: Returns the `Method` object for the given public method in
54
54
  # `self`.
55
55
  # * #public_methods: Returns an array of the symbol names of the public
56
56
  # methods in `self`.
57
57
  # * #respond_to?: Returns whether `self` responds to the given method.
58
58
  # * #singleton_class: Returns the singleton class of `self`.
59
- # * #singleton_method: Returns the Method object for the given singleton
59
+ # * #singleton_method: Returns the `Method` object for the given singleton
60
60
  # method in `self`.
61
61
  # * #singleton_methods: Returns an array of the symbol names of the singleton
62
62
  # methods in `self`.
@@ -29,6 +29,7 @@ module ObjectSpace
29
29
  # - _id2ref(p1)
30
30
  # -->
31
31
  #
32
+ %a{deprecated}
32
33
  def self._id2ref: (Integer id) -> untyped
33
34
 
34
35
  # <!--
@@ -159,6 +160,18 @@ module ObjectSpace
159
160
  # 2.2250738585072e-308
160
161
  # Total count: 7
161
162
  #
163
+ # Due to a current known Ractor implementation issue, this method will not yield
164
+ # Ractor-unshareable objects in multi-Ractor mode (when `Ractor.new` has been
165
+ # called within the process at least once). See
166
+ # https://bugs.ruby-lang.org/issues/19387 for more information.
167
+ #
168
+ # a = 12345678987654321 # shareable
169
+ # b = [].freeze # shareable
170
+ # c = {} # not shareable
171
+ # ObjectSpace.each_object {|x| x } # yields a, b, and c
172
+ # Ractor.new {} # enter multi-Ractor mode
173
+ # ObjectSpace.each_object {|x| x } # does not yield c
174
+ #
162
175
  def self.each_object: (?Module `module`) -> Enumerator[untyped, Integer]
163
176
  | (?Module `module`) { (untyped obj) -> void } -> Integer
164
177