rbs 3.9.4 → 3.10.2

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 (194) 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 +2 -2
  6. data/.github/workflows/ruby.yml +33 -19
  7. data/.github/workflows/typecheck.yml +1 -1
  8. data/.github/workflows/windows.yml +1 -1
  9. data/.gitignore +4 -0
  10. data/CHANGELOG.md +81 -0
  11. data/README.md +38 -1
  12. data/Rakefile +152 -23
  13. data/config.yml +190 -62
  14. data/core/array.rbs +96 -46
  15. data/core/comparable.rbs +13 -6
  16. data/core/complex.rbs +40 -25
  17. data/core/dir.rbs +4 -4
  18. data/core/encoding.rbs +6 -9
  19. data/core/enumerable.rbs +90 -3
  20. data/core/enumerator.rbs +43 -1
  21. data/core/errno.rbs +8 -0
  22. data/core/errors.rbs +28 -1
  23. data/core/exception.rbs +2 -2
  24. data/core/fiber.rbs +29 -20
  25. data/core/file.rbs +49 -19
  26. data/core/file_test.rbs +1 -1
  27. data/core/float.rbs +224 -33
  28. data/core/gc.rbs +417 -281
  29. data/core/hash.rbs +1023 -727
  30. data/core/integer.rbs +104 -63
  31. data/core/io/buffer.rbs +21 -10
  32. data/core/io/wait.rbs +11 -33
  33. data/core/io.rbs +14 -12
  34. data/core/kernel.rbs +61 -51
  35. data/core/marshal.rbs +1 -1
  36. data/core/match_data.rbs +1 -1
  37. data/core/math.rbs +42 -3
  38. data/core/method.rbs +63 -25
  39. data/core/module.rbs +101 -23
  40. data/core/nil_class.rbs +3 -3
  41. data/core/numeric.rbs +25 -17
  42. data/core/object.rbs +3 -3
  43. data/core/object_space.rbs +21 -15
  44. data/core/pathname.rbs +1272 -0
  45. data/core/proc.rbs +30 -24
  46. data/core/process.rbs +2 -2
  47. data/core/ractor.rbs +361 -509
  48. data/core/range.rbs +7 -8
  49. data/core/rational.rbs +56 -34
  50. data/core/rbs/unnamed/argf.rbs +2 -2
  51. data/core/rbs/unnamed/env_class.rbs +1 -1
  52. data/core/rbs/unnamed/random.rbs +4 -2
  53. data/core/regexp.rbs +25 -20
  54. data/core/ruby.rbs +53 -0
  55. data/core/ruby_vm.rbs +6 -4
  56. data/core/rubygems/errors.rbs +3 -70
  57. data/core/rubygems/rubygems.rbs +11 -79
  58. data/core/rubygems/version.rbs +2 -3
  59. data/core/set.rbs +488 -359
  60. data/core/signal.rbs +24 -14
  61. data/core/string.rbs +3164 -1235
  62. data/core/struct.rbs +1 -1
  63. data/core/symbol.rbs +17 -11
  64. data/core/thread.rbs +95 -33
  65. data/core/time.rbs +35 -9
  66. data/core/trace_point.rbs +7 -4
  67. data/core/unbound_method.rbs +14 -6
  68. data/docs/aliases.md +79 -0
  69. data/docs/collection.md +2 -2
  70. data/docs/encoding.md +56 -0
  71. data/docs/gem.md +0 -1
  72. data/docs/sigs.md +3 -3
  73. data/ext/rbs_extension/ast_translation.c +1016 -0
  74. data/ext/rbs_extension/ast_translation.h +37 -0
  75. data/ext/rbs_extension/class_constants.c +155 -0
  76. data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
  77. data/ext/rbs_extension/compat.h +10 -0
  78. data/ext/rbs_extension/extconf.rb +25 -1
  79. data/ext/rbs_extension/legacy_location.c +317 -0
  80. data/ext/rbs_extension/legacy_location.h +45 -0
  81. data/ext/rbs_extension/main.c +367 -23
  82. data/ext/rbs_extension/rbs_extension.h +6 -21
  83. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  84. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  85. data/include/rbs/ast.h +687 -0
  86. data/include/rbs/defines.h +86 -0
  87. data/include/rbs/lexer.h +199 -0
  88. data/include/rbs/location.h +59 -0
  89. data/include/rbs/parser.h +135 -0
  90. data/include/rbs/string.h +47 -0
  91. data/include/rbs/util/rbs_allocator.h +59 -0
  92. data/include/rbs/util/rbs_assert.h +20 -0
  93. data/include/rbs/util/rbs_buffer.h +83 -0
  94. data/include/rbs/util/rbs_constant_pool.h +6 -67
  95. data/include/rbs/util/rbs_encoding.h +282 -0
  96. data/include/rbs/util/rbs_unescape.h +24 -0
  97. data/include/rbs.h +1 -2
  98. data/lib/rbs/annotate/formatter.rb +3 -13
  99. data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
  100. data/lib/rbs/annotate/rdoc_source.rb +1 -1
  101. data/lib/rbs/cli/validate.rb +2 -2
  102. data/lib/rbs/cli.rb +1 -1
  103. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  104. data/lib/rbs/collection.rb +1 -0
  105. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
  106. data/lib/rbs/environment.rb +64 -59
  107. data/lib/rbs/environment_loader.rb +0 -6
  108. data/lib/rbs/errors.rb +1 -1
  109. data/lib/rbs/parser_aux.rb +5 -0
  110. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  111. data/lib/rbs/resolver/type_name_resolver.rb +124 -38
  112. data/lib/rbs/subtractor.rb +3 -1
  113. data/lib/rbs/test/type_check.rb +14 -0
  114. data/lib/rbs/types.rb +3 -1
  115. data/lib/rbs/version.rb +1 -1
  116. data/lib/rbs.rb +1 -1
  117. data/lib/rdoc/discover.rb +1 -1
  118. data/lib/rdoc_plugin/parser.rb +3 -3
  119. data/sig/annotate/formatter.rbs +2 -2
  120. data/sig/annotate/rdoc_annotater.rbs +1 -1
  121. data/sig/environment.rbs +57 -6
  122. data/sig/manifest.yaml +0 -1
  123. data/sig/parser.rbs +20 -0
  124. data/sig/resolver/type_name_resolver.rbs +38 -7
  125. data/sig/types.rbs +4 -1
  126. data/src/ast.c +1256 -0
  127. data/src/lexer.c +2956 -0
  128. data/src/lexer.re +147 -0
  129. data/src/lexstate.c +205 -0
  130. data/src/location.c +71 -0
  131. data/src/parser.c +3507 -0
  132. data/src/string.c +41 -0
  133. data/src/util/rbs_allocator.c +165 -0
  134. data/src/util/rbs_assert.c +19 -0
  135. data/src/util/rbs_buffer.c +54 -0
  136. data/src/util/rbs_constant_pool.c +18 -88
  137. data/src/util/rbs_encoding.c +21308 -0
  138. data/src/util/rbs_unescape.c +167 -0
  139. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  140. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  141. data/stdlib/cgi/0/core.rbs +9 -393
  142. data/stdlib/cgi/0/manifest.yaml +1 -0
  143. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  144. data/stdlib/coverage/0/coverage.rbs +3 -1
  145. data/stdlib/date/0/date.rbs +67 -59
  146. data/stdlib/date/0/date_time.rbs +1 -1
  147. data/stdlib/delegate/0/delegator.rbs +10 -7
  148. data/stdlib/erb/0/erb.rbs +737 -347
  149. data/stdlib/fileutils/0/fileutils.rbs +18 -13
  150. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  151. data/stdlib/json/0/json.rbs +68 -48
  152. data/stdlib/net-http/0/net-http.rbs +3 -0
  153. data/stdlib/objspace/0/objspace.rbs +9 -4
  154. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  155. data/stdlib/openssl/0/openssl.rbs +331 -228
  156. data/stdlib/optparse/0/optparse.rbs +3 -3
  157. data/stdlib/pathname/0/pathname.rbs +9 -1379
  158. data/stdlib/psych/0/psych.rbs +3 -3
  159. data/stdlib/rdoc/0/code_object.rbs +2 -2
  160. data/stdlib/rdoc/0/comment.rbs +2 -0
  161. data/stdlib/rdoc/0/options.rbs +76 -0
  162. data/stdlib/rdoc/0/rdoc.rbs +7 -5
  163. data/stdlib/rdoc/0/store.rbs +1 -1
  164. data/stdlib/resolv/0/resolv.rbs +25 -68
  165. data/stdlib/ripper/0/ripper.rbs +5 -2
  166. data/stdlib/singleton/0/singleton.rbs +3 -0
  167. data/stdlib/socket/0/socket.rbs +13 -1
  168. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  169. data/stdlib/stringio/0/stringio.rbs +1176 -85
  170. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  171. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  172. data/stdlib/time/0/time.rbs +1 -1
  173. data/stdlib/timeout/0/timeout.rbs +63 -7
  174. data/stdlib/tsort/0/cyclic.rbs +3 -0
  175. data/stdlib/uri/0/common.rbs +11 -2
  176. data/stdlib/uri/0/file.rbs +1 -1
  177. data/stdlib/uri/0/generic.rbs +17 -16
  178. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  179. data/stdlib/zlib/0/zstream.rbs +1 -0
  180. metadata +44 -18
  181. data/ext/rbs_extension/lexer.c +0 -2728
  182. data/ext/rbs_extension/lexer.h +0 -179
  183. data/ext/rbs_extension/lexer.re +0 -147
  184. data/ext/rbs_extension/lexstate.c +0 -175
  185. data/ext/rbs_extension/location.c +0 -325
  186. data/ext/rbs_extension/location.h +0 -85
  187. data/ext/rbs_extension/parser.c +0 -2982
  188. data/ext/rbs_extension/parser.h +0 -18
  189. data/ext/rbs_extension/parserstate.c +0 -411
  190. data/ext/rbs_extension/parserstate.h +0 -163
  191. data/ext/rbs_extension/unescape.c +0 -32
  192. data/include/rbs/ruby_objs.h +0 -72
  193. data/src/constants.c +0 -153
  194. data/src/ruby_objs.c +0 -799
data/core/array.rbs CHANGED
@@ -151,8 +151,8 @@
151
151
  #
152
152
  # ## Example Usage
153
153
  #
154
- # In addition to the methods it mixes in through the Enumerable module, the
155
- # `Array` class has proprietary methods for accessing, searching and otherwise
154
+ # In addition to the methods it mixes in through the Enumerable module, class
155
+ # Array has proprietary methods for accessing, searching and otherwise
156
156
  # manipulating arrays.
157
157
  #
158
158
  # Some of the more common ones are illustrated below.
@@ -200,9 +200,9 @@
200
200
  #
201
201
  # arr.drop(3) #=> [4, 5, 6]
202
202
  #
203
- # ## Obtaining Information about an `Array`
203
+ # ## Obtaining Information about an Array
204
204
  #
205
- # Arrays keep track of their own length at all times. To query an array about
205
+ # An array keeps track of its own length at all times. To query an array about
206
206
  # the number of elements it contains, use #length, #count or #size.
207
207
  #
208
208
  # browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE']
@@ -217,7 +217,7 @@
217
217
  #
218
218
  # browsers.include?('Konqueror') #=> false
219
219
  #
220
- # ## Adding Items to Arrays
220
+ # ## Adding Items to an Array
221
221
  #
222
222
  # Items can be added to the end of an array by using either #push or #<<
223
223
  #
@@ -238,7 +238,7 @@
238
238
  # arr.insert(3, 'orange', 'pear', 'grapefruit')
239
239
  # #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6]
240
240
  #
241
- # ## Removing Items from an `Array`
241
+ # ## Removing Items from an Array
242
242
  #
243
243
  # The method #pop removes the last element in an array and returns it:
244
244
  #
@@ -277,12 +277,12 @@
277
277
  # arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556]
278
278
  # arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123]
279
279
  #
280
- # ## Iterating over Arrays
280
+ # ## Iterating over an Array
281
281
  #
282
- # Like all classes that include the Enumerable module, `Array` has an each
282
+ # Like all classes that include the Enumerable module, class Array has an each
283
283
  # method, which defines what elements should be iterated over and how. In case
284
- # of Array's #each, all elements in the `Array` instance are yielded to the
285
- # supplied block in sequence.
284
+ # of Array#each, all elements in `self` are yielded to the supplied block in
285
+ # sequence.
286
286
  #
287
287
  # Note that this operation leaves the array unchanged.
288
288
  #
@@ -307,7 +307,7 @@
307
307
  # arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25]
308
308
  # arr #=> [1, 4, 9, 16, 25]
309
309
  #
310
- # ## Selecting Items from an `Array`
310
+ # ## Selecting Items from an Array
311
311
  #
312
312
  # Elements can be selected from an array according to criteria defined in a
313
313
  # block. The selection can happen in a destructive or a non-destructive manner.
@@ -340,13 +340,13 @@
340
340
  #
341
341
  # ## What's Here
342
342
  #
343
- # First, what's elsewhere. Class `Array`:
343
+ # First, what's elsewhere. Class Array:
344
344
  #
345
345
  # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
346
346
  # * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
347
347
  # provides dozens of additional methods.
348
348
  #
349
- # Here, class `Array` provides methods that are useful for:
349
+ # Here, class Array provides methods that are useful for:
350
350
  #
351
351
  # * [Creating an Array](rdoc-ref:Array@Methods+for+Creating+an+Array)
352
352
  # * [Querying](rdoc-ref:Array@Methods+for+Querying)
@@ -359,7 +359,7 @@
359
359
  # * [Converting](rdoc-ref:Array@Methods+for+Converting)
360
360
  # * [And more....](rdoc-ref:Array@Other+Methods)
361
361
  #
362
- # ### Methods for Creating an `Array`
362
+ # ### Methods for Creating an Array
363
363
  #
364
364
  # * ::[]: Returns a new array populated with given objects.
365
365
  # * ::new: Returns a new array.
@@ -524,7 +524,7 @@
524
524
  # return-value.
525
525
  # * #flatten: Returns an array that is a recursive flattening of `self`.
526
526
  # * #inspect (aliased as #to_s): Returns a new String containing the elements.
527
- # * #join: Returns a newsString containing the elements joined by the field
527
+ # * #join: Returns a new String containing the elements joined by the field
528
528
  # separator.
529
529
  # * #to_a: Returns `self` or a new array containing all elements.
530
530
  # * #to_ary: Returns `self`.
@@ -840,9 +840,8 @@ class Array[unchecked out Elem] < Object
840
840
  #
841
841
  # If `index` is out of range, returns `nil`.
842
842
  #
843
- # When two Integer arguments `start` and `length` are given, returns a new
844
- # `Array` of size `length` containing successive elements beginning at offset
845
- # `start`:
843
+ # When two Integer arguments `start` and `length` are given, returns a new array
844
+ # of size `length` containing successive elements beginning at offset `start`:
846
845
  #
847
846
  # a = [:foo, 'bar', 2]
848
847
  # a[0, 2] # => [:foo, "bar"]
@@ -856,7 +855,7 @@ class Array[unchecked out Elem] < Object
856
855
  # a[1, 3] # => ["bar", 2]
857
856
  # a[2, 2] # => [2]
858
857
  #
859
- # If `start == self.size` and `length >= 0`, returns a new empty `Array`.
858
+ # If `start == self.size` and `length >= 0`, returns a new empty array.
860
859
  #
861
860
  # If `length` is negative, returns `nil`.
862
861
  #
@@ -867,7 +866,7 @@ class Array[unchecked out Elem] < Object
867
866
  # a[0..1] # => [:foo, "bar"]
868
867
  # a[1..2] # => ["bar", 2]
869
868
  #
870
- # Special case: If `range.start == a.size`, returns a new empty `Array`.
869
+ # Special case: If `range.start == a.size`, returns a new empty array.
871
870
  #
872
871
  # If `range.end` is negative, calculates the end index from the end:
873
872
  #
@@ -891,7 +890,7 @@ class Array[unchecked out Elem] < Object
891
890
  # a[4..-1] # => nil
892
891
  #
893
892
  # When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
894
- # an `Array` of elements corresponding to the indexes produced by the sequence.
893
+ # an array of elements corresponding to the indexes produced by the sequence.
895
894
  #
896
895
  # a = ['--', 'data1', '--', 'data2', '--', 'data3']
897
896
  # a[(1..).step(2)] # => ["data1", "data2", "data3"]
@@ -976,8 +975,8 @@ class Array[unchecked out Elem] < Object
976
975
  # a # => [:foo, "bar", "two"]
977
976
  #
978
977
  # When Integer arguments `start` and `length` are given and `object` is not an
979
- # `Array`, removes `length - 1` elements beginning at offset `start`, and
980
- # assigns `object` at offset `start`:
978
+ # array, removes `length - 1` elements beginning at offset `start`, and assigns
979
+ # `object` at offset `start`:
981
980
  #
982
981
  # a = [:foo, 'bar', 2]
983
982
  # a[0, 2] = 'foo' # => "foo"
@@ -1010,7 +1009,7 @@ class Array[unchecked out Elem] < Object
1010
1009
  # a[1, 5] = 'foo' # => "foo"
1011
1010
  # a # => [:foo, "foo"]
1012
1011
  #
1013
- # When Range argument `range` is given and `object` is not an `Array`, removes
1012
+ # When Range argument `range` is given and `object` is not an array, removes
1014
1013
  # `length - 1` elements beginning at offset `start`, and assigns `object` at
1015
1014
  # offset `start`:
1016
1015
  #
@@ -1214,7 +1213,7 @@ class Array[unchecked out Elem] < Object
1214
1213
  # Returns the element from `self` found by a binary search, or `nil` if the
1215
1214
  # search found no suitable element.
1216
1215
  #
1217
- # See [Binary Searching](rdoc-ref:bsearch.rdoc).
1216
+ # See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
1218
1217
  #
1219
1218
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1220
1219
  #
@@ -1230,7 +1229,7 @@ class Array[unchecked out Elem] < Object
1230
1229
  # Returns the integer index of the element from `self` found by a binary search,
1231
1230
  # or `nil` if the search found no suitable element.
1232
1231
  #
1233
- # See [Binary Searching](rdoc-ref:bsearch.rdoc).
1232
+ # See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
1234
1233
  #
1235
1234
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
1236
1235
  #
@@ -1274,9 +1273,9 @@ class Array[unchecked out Elem] < Object
1274
1273
 
1275
1274
  # <!--
1276
1275
  # rdoc-file=array.c
1277
- # - collect! {|element| ... } -> new_array
1276
+ # - collect! {|element| ... } -> self
1278
1277
  # - collect! -> new_enumerator
1279
- # - map! {|element| ... } -> new_array
1278
+ # - map! {|element| ... } -> self
1280
1279
  # - map! -> new_enumerator
1281
1280
  # -->
1282
1281
  # With a block given, calls the block with each element of `self` and replaces
@@ -1564,7 +1563,7 @@ class Array[unchecked out Elem] < Object
1564
1563
 
1565
1564
  # <!--
1566
1565
  # rdoc-file=array.c
1567
- # - array.dig(index, *identifiers) -> object
1566
+ # - dig(index, *identifiers) -> object
1568
1567
  # -->
1569
1568
  # Finds and returns the object in nested object specified by `index` and
1570
1569
  # `identifiers`; the nested objects may be instances of various classes. See
@@ -1693,7 +1692,7 @@ class Array[unchecked out Elem] < Object
1693
1692
 
1694
1693
  # <!--
1695
1694
  # rdoc-file=array.c
1696
- # - array.empty? -> true or false
1695
+ # - empty? -> true or false
1697
1696
  # -->
1698
1697
  # Returns `true` if the count of elements in `self` is zero, `false` otherwise.
1699
1698
  #
@@ -1804,10 +1803,10 @@ class Array[unchecked out Elem] < Object
1804
1803
 
1805
1804
  # <!--
1806
1805
  # rdoc-file=array.c
1807
- # - fill(object, start = nil, count = nil) -> new_array
1808
- # - fill(object, range) -> new_array
1809
- # - fill(start = nil, count = nil) {|element| ... } -> new_array
1810
- # - fill(range) {|element| ... } -> new_array
1806
+ # - fill(object, start = nil, count = nil) -> self
1807
+ # - fill(object, range) -> self
1808
+ # - fill(start = nil, count = nil) {|element| ... } -> self
1809
+ # - fill(range) {|element| ... } -> self
1811
1810
  # -->
1812
1811
  # Replaces selected elements in `self`; may add elements to `self`; always
1813
1812
  # returns `self` (never a new array).
@@ -2020,6 +2019,30 @@ class Array[unchecked out Elem] < Object
2020
2019
  def filter!: () { (Elem item) -> boolish } -> self?
2021
2020
  | () -> ::Enumerator[Elem, self?]
2022
2021
 
2022
+ # <!--
2023
+ # rdoc-file=array.c
2024
+ # - find(if_none_proc = nil) {|element| ... } -> object or nil
2025
+ # - find(if_none_proc = nil) -> enumerator
2026
+ # -->
2027
+ # Returns the first element for which the block returns a truthy value.
2028
+ #
2029
+ # With a block given, calls the block with successive elements of the array;
2030
+ # returns the first element for which the block returns a truthy value:
2031
+ #
2032
+ # [1, 3, 5].find {|element| element > 2} # => 3
2033
+ #
2034
+ # If no such element is found, calls `if_none_proc` and returns its return
2035
+ # value.
2036
+ #
2037
+ # [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
2038
+ #
2039
+ # With no block given, returns an Enumerator.
2040
+ #
2041
+ def find: () { (Elem) -> boolish } -> Elem?
2042
+ | () -> ::Enumerator[Elem, Elem?]
2043
+ | [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
2044
+ | [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
2045
+
2023
2046
  # <!--
2024
2047
  # rdoc-file=array.c
2025
2048
  # - find_index(object) -> integer or nil
@@ -2300,7 +2323,7 @@ class Array[unchecked out Elem] < Object
2300
2323
 
2301
2324
  # <!--
2302
2325
  # rdoc-file=array.c
2303
- # - array.join(separator = $,) -> new_string
2326
+ # - join(separator = $,) -> new_string
2304
2327
  # -->
2305
2328
  # Returns the new string formed by joining the converted elements of `self`; for
2306
2329
  # each element `element`:
@@ -2619,7 +2642,7 @@ class Array[unchecked out Elem] < Object
2619
2642
  # - pack(template, buffer: nil) -> string
2620
2643
  # -->
2621
2644
  # Formats each element in `self` into a binary string; returns that string. See
2622
- # [Packed Data](rdoc-ref:packed_data.rdoc).
2645
+ # [Packed Data](rdoc-ref:language/packed_data.rdoc).
2623
2646
  #
2624
2647
  def pack: (string fmt, ?buffer: String?) -> String
2625
2648
 
@@ -2989,6 +3012,31 @@ class Array[unchecked out Elem] < Object
2989
3012
  def reverse_each: () { (Elem item) -> void } -> self
2990
3013
  | () -> ::Enumerator[Elem, self]
2991
3014
 
3015
+ # <!--
3016
+ # rdoc-file=array.c
3017
+ # - rfind(if_none_proc = nil) {|element| ... } -> object or nil
3018
+ # - rfind(if_none_proc = nil) -> enumerator
3019
+ # -->
3020
+ # Returns the last element for which the block returns a truthy value.
3021
+ #
3022
+ # With a block given, calls the block with successive elements of the array in
3023
+ # reverse order; returns the first element for which the block returns a truthy
3024
+ # value:
3025
+ #
3026
+ # [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4
3027
+ #
3028
+ # If no such element is found, calls `if_none_proc` and returns its return
3029
+ # value.
3030
+ #
3031
+ # [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0
3032
+ #
3033
+ # With no block given, returns an Enumerator.
3034
+ #
3035
+ def rfind: () { (Elem) -> boolish } -> Elem?
3036
+ | () -> ::Enumerator[Elem, Elem?]
3037
+ | [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
3038
+ | [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
3039
+
2992
3040
  # <!--
2993
3041
  # rdoc-file=array.c
2994
3042
  # - rindex(object) -> integer or nil
@@ -3115,7 +3163,7 @@ class Array[unchecked out Elem] < Object
3115
3163
  #
3116
3164
  # The order of the result array is unrelated to the order of `self`.
3117
3165
  #
3118
- # Returns a new empty `Array` if `self` is empty:
3166
+ # Returns a new empty array if `self` is empty:
3119
3167
  #
3120
3168
  # [].sample(4) # => []
3121
3169
  #
@@ -3320,9 +3368,8 @@ class Array[unchecked out Elem] < Object
3320
3368
  #
3321
3369
  # If `index` is out of range, returns `nil`.
3322
3370
  #
3323
- # When two Integer arguments `start` and `length` are given, returns a new
3324
- # `Array` of size `length` containing successive elements beginning at offset
3325
- # `start`:
3371
+ # When two Integer arguments `start` and `length` are given, returns a new array
3372
+ # of size `length` containing successive elements beginning at offset `start`:
3326
3373
  #
3327
3374
  # a = [:foo, 'bar', 2]
3328
3375
  # a[0, 2] # => [:foo, "bar"]
@@ -3336,7 +3383,7 @@ class Array[unchecked out Elem] < Object
3336
3383
  # a[1, 3] # => ["bar", 2]
3337
3384
  # a[2, 2] # => [2]
3338
3385
  #
3339
- # If `start == self.size` and `length >= 0`, returns a new empty `Array`.
3386
+ # If `start == self.size` and `length >= 0`, returns a new empty array.
3340
3387
  #
3341
3388
  # If `length` is negative, returns `nil`.
3342
3389
  #
@@ -3347,7 +3394,7 @@ class Array[unchecked out Elem] < Object
3347
3394
  # a[0..1] # => [:foo, "bar"]
3348
3395
  # a[1..2] # => ["bar", 2]
3349
3396
  #
3350
- # Special case: If `range.start == a.size`, returns a new empty `Array`.
3397
+ # Special case: If `range.start == a.size`, returns a new empty array.
3351
3398
  #
3352
3399
  # If `range.end` is negative, calculates the end index from the end:
3353
3400
  #
@@ -3371,7 +3418,7 @@ class Array[unchecked out Elem] < Object
3371
3418
  # a[4..-1] # => nil
3372
3419
  #
3373
3420
  # When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
3374
- # an `Array` of elements corresponding to the indexes produced by the sequence.
3421
+ # an array of elements corresponding to the indexes produced by the sequence.
3375
3422
  #
3376
3423
  # a = ['--', 'data1', '--', 'data2', '--', 'data3']
3377
3424
  # a[(1..).step(2)] # => ["data1", "data2", "data3"]
@@ -3518,6 +3565,9 @@ class Array[unchecked out Elem] < Object
3518
3565
  # When the block returns zero, the order for `a` and `b` is indeterminate, and
3519
3566
  # may be unstable.
3520
3567
  #
3568
+ # See an example in Numeric#nonzero? for the idiom to sort more complex
3569
+ # structure.
3570
+ #
3521
3571
  # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
3522
3572
  #
3523
3573
  def sort: () -> ::Array[Elem]
@@ -3647,7 +3697,7 @@ class Array[unchecked out Elem] < Object
3647
3697
  # rdoc-file=array.c
3648
3698
  # - to_a -> self or new_array
3649
3699
  # -->
3650
- # When `self` is an instance of `Array`, returns `self`.
3700
+ # When `self` is an instance of Array, returns `self`.
3651
3701
  #
3652
3702
  # Otherwise, returns a new array containing the elements of `self`:
3653
3703
  #
@@ -3663,7 +3713,7 @@ class Array[unchecked out Elem] < Object
3663
3713
 
3664
3714
  # <!--
3665
3715
  # rdoc-file=array.c
3666
- # - array.to_ary -> self
3716
+ # - to_ary -> self
3667
3717
  # -->
3668
3718
  # Returns `self`.
3669
3719
  #
@@ -4008,7 +4058,7 @@ class Array[unchecked out Elem] < Object
4008
4058
  # [:c3, :b3, :a3]]
4009
4059
  #
4010
4060
  # For an **object** in **other_arrays** that is not actually an array, forms the
4011
- # the "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
4061
+ # "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
4012
4062
  # otherwise.
4013
4063
  #
4014
4064
  # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
data/core/comparable.rbs CHANGED
@@ -55,19 +55,26 @@
55
55
  module Comparable : _WithSpaceshipOperator
56
56
  # <!--
57
57
  # rdoc-file=compar.c
58
- # - obj < other -> true or false
58
+ # - self < other -> true or false
59
59
  # -->
60
- # Compares two objects based on the receiver's `<=>` method, returning true if
61
- # it returns a value less than 0.
60
+ # Returns whether `self` is "less than" `other`; equivalent to `(self <=> other)
61
+ # < 0`:
62
+ #
63
+ # 'foo' < 'foo' # => false
64
+ # 'foo' < 'food' # => true
62
65
  #
63
66
  def <: (untyped other) -> bool
64
67
 
65
68
  # <!--
66
69
  # rdoc-file=compar.c
67
- # - obj <= other -> true or false
70
+ # - self <= other -> true or false
68
71
  # -->
69
- # Compares two objects based on the receiver's `<=>` method, returning true if
70
- # it returns a value less than or equal to 0.
72
+ # Returns whether `self` is "less than or equal to" `other`; equivalent to
73
+ # `(self <=> other) <= 0`:
74
+ #
75
+ # 'foo' <= 'foo' # => true
76
+ # 'foo' <= 'food' # => true
77
+ # 'food' <= 'foo' # => false
71
78
  #
72
79
  def <=: (untyped other) -> bool
73
80
 
data/core/complex.rbs CHANGED
@@ -184,23 +184,24 @@ class Complex < Numeric
184
184
 
185
185
  # <!--
186
186
  # rdoc-file=complex.c
187
- # - complex * numeric -> new_complex
187
+ # - self * other -> numeric
188
188
  # -->
189
- # Returns the product of `self` and `numeric`:
189
+ # Returns the numeric product of `self` and `other`:
190
190
  #
191
+ # Complex.rect(9, 8) * 4 # => (36+32i)
192
+ # Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
191
193
  # Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
192
194
  # Complex.rect(900) * Complex.rect(1) # => (900+0i)
193
195
  # Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
194
- # Complex.rect(9, 8) * 4 # => (36+32i)
195
- # Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
196
+ # Complex.rect(9, 8) * Rational(2, 3) # => ((6/1)+(16/3)*i)
196
197
  #
197
198
  def *: (Numeric) -> Complex
198
199
 
199
200
  # <!--
200
201
  # rdoc-file=complex.c
201
- # - complex ** numeric -> new_complex
202
+ # - self ** exponent -> complex
202
203
  # -->
203
- # Returns `self` raised to power `numeric`:
204
+ # Returns `self` raised to the power `exponent`:
204
205
  #
205
206
  # Complex.rect(0, 1) ** 2 # => (-1+0i)
206
207
  # Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
@@ -209,15 +210,25 @@ class Complex < Numeric
209
210
 
210
211
  # <!--
211
212
  # rdoc-file=complex.c
212
- # - complex + numeric -> new_complex
213
+ # - self + other -> numeric
213
214
  # -->
214
- # Returns the sum of `self` and `numeric`:
215
+ # Returns the sum of `self` and `other`:
216
+ #
217
+ # Complex(1, 2) + 0 # => (1+2i)
218
+ # Complex(1, 2) + 1 # => (2+2i)
219
+ # Complex(1, 2) + -1 # => (0+2i)
220
+ #
221
+ # Complex(1, 2) + 1.0 # => (2.0+2i)
215
222
  #
216
- # Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
217
- # Complex.rect(900) + Complex.rect(1) # => (901+0i)
218
- # Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
219
- # Complex.rect(9, 8) + 4 # => (13+8i)
220
- # Complex.rect(20, 9) + 9.8 # => (29.8+9i)
223
+ # Complex(1, 2) + Complex(2, 1) # => (3+3i)
224
+ # Complex(1, 2) + Complex(2.0, 1.0) # => (3.0+3.0i)
225
+ #
226
+ # Complex(1, 2) + Rational(1, 1) # => ((2/1)+2i)
227
+ # Complex(1, 2) + Rational(1, 2) # => ((3/2)+2i)
228
+ #
229
+ # For a computation involving Floats, the result may be inexact (see Float#+):
230
+ #
231
+ # Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
221
232
  #
222
233
  def +: (Numeric) -> Complex
223
234
 
@@ -225,9 +236,9 @@ class Complex < Numeric
225
236
 
226
237
  # <!--
227
238
  # rdoc-file=complex.c
228
- # - complex - numeric -> new_complex
239
+ # - self - other -> complex
229
240
  # -->
230
- # Returns the difference of `self` and `numeric`:
241
+ # Returns the difference of `self` and `other`:
231
242
  #
232
243
  # Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
233
244
  # Complex.rect(900) - Complex.rect(1) # => (899+0i)
@@ -239,9 +250,9 @@ class Complex < Numeric
239
250
 
240
251
  # <!--
241
252
  # rdoc-file=complex.c
242
- # - -complex -> new_complex
253
+ # - -self -> complex
243
254
  # -->
244
- # Returns the negation of `self`, which is the negation of each of its parts:
255
+ # Returns `self`, negated, which is the negation of each of its parts:
245
256
  #
246
257
  # -Complex.rect(1, 2) # => (-1-2i)
247
258
  # -Complex.rect(-1, -2) # => (1+2i)
@@ -250,9 +261,9 @@ class Complex < Numeric
250
261
 
251
262
  # <!--
252
263
  # rdoc-file=complex.c
253
- # - complex / numeric -> new_complex
264
+ # - self / other -> complex
254
265
  # -->
255
- # Returns the quotient of `self` and `numeric`:
266
+ # Returns the quotient of `self` and `other`:
256
267
  #
257
268
  # Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
258
269
  # Complex.rect(900) / Complex.rect(1) # => (900+0i)
@@ -268,15 +279,16 @@ class Complex < Numeric
268
279
 
269
280
  # <!--
270
281
  # rdoc-file=complex.c
271
- # - complex <=> object -> -1, 0, 1, or nil
282
+ # - self <=> other -> -1, 0, 1, or nil
272
283
  # -->
284
+ # Compares `self` and `other`.
285
+ #
273
286
  # Returns:
274
287
  #
275
- # * `self.real <=> object.real` if both of the following are true:
288
+ # * `self.real <=> other.real` if both of the following are true:
276
289
  #
277
290
  # * `self.imag == 0`.
278
- # * `object.imag == 0`. # Always true if object is numeric but not
279
- # complex.
291
+ # * `other.imag == 0` (always true if `other` is numeric but not complex).
280
292
  #
281
293
  # * `nil` otherwise.
282
294
  #
@@ -289,6 +301,9 @@ class Complex < Numeric
289
301
  # Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
290
302
  # Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
291
303
  #
304
+ # Class Complex includes module Comparable, each of whose methods uses
305
+ # Complex#<=> for comparison.
306
+ #
292
307
  def <=>: (untyped) -> Integer?
293
308
 
294
309
  # <!--
@@ -594,9 +609,9 @@ class Complex < Numeric
594
609
 
595
610
  # <!--
596
611
  # rdoc-file=complex.c
597
- # - complex / numeric -> new_complex
612
+ # - self / other -> complex
598
613
  # -->
599
- # Returns the quotient of `self` and `numeric`:
614
+ # Returns the quotient of `self` and `other`:
600
615
  #
601
616
  # Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
602
617
  # Complex.rect(900) / Complex.rect(1) # => (900+0i)
data/core/dir.rbs CHANGED
@@ -171,7 +171,7 @@ class Dir
171
171
  # system's encoding is used:
172
172
  #
173
173
  # Dir.new('.').read.encoding # => #<Encoding:UTF-8>
174
- # Dir.new('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
174
+ # Dir.new('.', encoding: Encoding::US_ASCI).read.encoding # => #<Encoding:US-ASCII>
175
175
  #
176
176
  def initialize: (path dir, ?encoding: encoding?) -> void
177
177
 
@@ -477,8 +477,8 @@ class Dir
477
477
 
478
478
  # <!--
479
479
  # rdoc-file=dir.rb
480
- # - Dir.glob(*patterns, flags: 0, base: nil, sort: true) -> array
481
- # - Dir.glob(*patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
480
+ # - Dir.glob(patterns, flags: 0, base: nil, sort: true) -> array
481
+ # - Dir.glob(patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
482
482
  # -->
483
483
  # Forms an array *entry_names* of the entry names selected by the arguments.
484
484
  #
@@ -704,7 +704,7 @@ class Dir
704
704
  # system's encoding is used:
705
705
  #
706
706
  # Dir.open('.').read.encoding # => #<Encoding:UTF-8>
707
- # Dir.open('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
707
+ # Dir.open('.', encoding: Encoding::US_ASCII).read.encoding # => #<Encoding:US-ASCII>
708
708
  #
709
709
  def self.open: (path dirname, ?encoding: encoding?) -> instance
710
710
  | [U] (path dirname, ?encoding: encoding?) { (instance) -> U } -> U
data/core/encoding.rbs CHANGED
@@ -281,7 +281,7 @@ class Encoding
281
281
  def inspect: () -> String
282
282
 
283
283
  # <!-- rdoc-file=encoding.c -->
284
- # Returns the name of the encoding.
284
+ # The name of the encoding.
285
285
  #
286
286
  # Encoding::UTF_8.name #=> "UTF-8"
287
287
  #
@@ -297,12 +297,8 @@ class Encoding
297
297
  #
298
298
  def names: () -> Array[String]
299
299
 
300
- # <!--
301
- # rdoc-file=encoding.c
302
- # - enc.name -> string
303
- # - enc.to_s -> string
304
- # -->
305
- # Returns the name of the encoding.
300
+ # <!-- rdoc-file=encoding.c -->
301
+ # The name of the encoding.
306
302
  #
307
303
  # Encoding::UTF_8.name #=> "UTF-8"
308
304
  #
@@ -923,8 +919,9 @@ class Encoding::Converter < Object
923
919
  # p ec.primitive_convert(src, dst, nil, 1) #=> :destination_buffer_full
924
920
  # p ec.last_error #=> nil
925
921
  #
926
- def last_error: () -> Encoding::InvalidByteSequenceError?
927
- | () -> Encoding::UndefinedConversionError?
922
+ def last_error: () -> ( Encoding::InvalidByteSequenceError
923
+ | Encoding::UndefinedConversionError
924
+ | nil )
928
925
 
929
926
  # <!--
930
927
  # rdoc-file=transcode.c