rbs 4.0.0.dev.4 → 4.0.0.dev.5

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 (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
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/binding.rbs CHANGED
@@ -32,8 +32,6 @@
32
32
  class Binding
33
33
  def clone: () -> self
34
34
 
35
- def dup: () -> self
36
-
37
35
  # <!--
38
36
  # rdoc-file=proc.c
39
37
  # - binding.eval(string [, filename [,lineno]]) -> obj
data/core/builtin.rbs CHANGED
@@ -9,7 +9,7 @@ end
9
9
  # A type that's convertible to a `Rational`.
10
10
  #
11
11
  interface _ToR
12
- # Convert `self` to a `Complex`.
12
+ # Convert `self` to a `Rational`.
13
13
  #
14
14
  def to_r: () -> Rational
15
15
  end
@@ -58,7 +58,7 @@ end
58
58
  #
59
59
  # Implicit `.to_str` conversions are usable all over Ruby's stdlib, such as `Kernel#abort`,
60
60
  # `String#+`, and `Object#send`. Virtually anywhere that accepts a `String` will also accept
61
- # something that defines `.to_Str`.
61
+ # something that defines `.to_str`.
62
62
  #
63
63
  # Types that define `.to_str` are also usable wherever paths are expected (See the `path` type
64
64
  # alias).
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,25 +210,33 @@ 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
 
224
- def +@: () -> Complex
225
-
226
235
  # <!--
227
236
  # rdoc-file=complex.c
228
- # - complex - numeric -> new_complex
237
+ # - self - other -> complex
229
238
  # -->
230
- # Returns the difference of `self` and `numeric`:
239
+ # Returns the difference of `self` and `other`:
231
240
  #
232
241
  # Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
233
242
  # Complex.rect(900) - Complex.rect(1) # => (899+0i)
@@ -239,9 +248,9 @@ class Complex < Numeric
239
248
 
240
249
  # <!--
241
250
  # rdoc-file=complex.c
242
- # - -complex -> new_complex
251
+ # - -self -> complex
243
252
  # -->
244
- # Returns the negation of `self`, which is the negation of each of its parts:
253
+ # Returns `self`, negated, which is the negation of each of its parts:
245
254
  #
246
255
  # -Complex.rect(1, 2) # => (-1-2i)
247
256
  # -Complex.rect(-1, -2) # => (1+2i)
@@ -250,9 +259,9 @@ class Complex < Numeric
250
259
 
251
260
  # <!--
252
261
  # rdoc-file=complex.c
253
- # - complex / numeric -> new_complex
262
+ # - self / other -> complex
254
263
  # -->
255
- # Returns the quotient of `self` and `numeric`:
264
+ # Returns the quotient of `self` and `other`:
256
265
  #
257
266
  # Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
258
267
  # Complex.rect(900) / Complex.rect(1) # => (900+0i)
@@ -268,15 +277,16 @@ class Complex < Numeric
268
277
 
269
278
  # <!--
270
279
  # rdoc-file=complex.c
271
- # - complex <=> object -> -1, 0, 1, or nil
280
+ # - self <=> other -> -1, 0, 1, or nil
272
281
  # -->
282
+ # Compares `self` and `other`.
283
+ #
273
284
  # Returns:
274
285
  #
275
- # * `self.real <=> object.real` if both of the following are true:
286
+ # * `self.real <=> other.real` if both of the following are true:
276
287
  #
277
288
  # * `self.imag == 0`.
278
- # * `object.imag == 0`. # Always true if object is numeric but not
279
- # complex.
289
+ # * `other.imag == 0` (always true if `other` is numeric but not complex).
280
290
  #
281
291
  # * `nil` otherwise.
282
292
  #
@@ -289,6 +299,9 @@ class Complex < Numeric
289
299
  # Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
290
300
  # Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
291
301
  #
302
+ # Class Complex includes module Comparable, each of whose methods uses
303
+ # Complex#<=> for comparison.
304
+ #
292
305
  def <=>: (untyped) -> Integer?
293
306
 
294
307
  # <!--
@@ -379,7 +392,7 @@ class Complex < Numeric
379
392
  #
380
393
  # Complex.rect(1, 2).conj # => (1-2i)
381
394
  #
382
- def conj: () -> Complex
395
+ def conj: () -> self
383
396
 
384
397
  # <!--
385
398
  # rdoc-file=complex.c
@@ -389,7 +402,7 @@ class Complex < Numeric
389
402
  #
390
403
  # Complex.rect(1, 2).conj # => (1-2i)
391
404
  #
392
- def conjugate: () -> Complex
405
+ def conjugate: () -> self
393
406
 
394
407
  # <!--
395
408
  # rdoc-file=complex.c
@@ -411,10 +424,6 @@ class Complex < Numeric
411
424
 
412
425
  def divmod: (Numeric) -> bot
413
426
 
414
- def dup: () -> self
415
-
416
- def eql?: (untyped) -> bool
417
-
418
427
  # <!--
419
428
  # rdoc-file=complex.c
420
429
  # - fdiv(numeric) -> new_complex
@@ -454,6 +463,19 @@ class Complex < Numeric
454
463
  #
455
464
  def hash: () -> Integer
456
465
 
466
+ # <!--
467
+ # rdoc-file=numeric.c
468
+ # - i -> complex
469
+ # -->
470
+ # Returns `Complex(0, self)`:
471
+ #
472
+ # 2.i # => (0+2i)
473
+ # -2.i # => (0-2i)
474
+ # 2.0.i # => (0+2.0i)
475
+ # Rational(1, 2).i # => (0+(1/2)*i)
476
+ # Complex(3, 4).i # Raises NoMethodError.
477
+ #
478
+ %a{annotate:rdoc:copy:Numeric#i}
457
479
  def i: () -> bot
458
480
 
459
481
  # <!-- rdoc-file=complex.c -->
@@ -515,8 +537,6 @@ class Complex < Numeric
515
537
  #
516
538
  def inspect: () -> String
517
539
 
518
- def integer?: () -> bool
519
-
520
540
  # <!-- rdoc-file=complex.c -->
521
541
  # Returns the absolute value (magnitude) for `self`; see [polar
522
542
  # coordinates](rdoc-ref:Complex@Polar+Coordinates):
@@ -535,8 +555,6 @@ class Complex < Numeric
535
555
 
536
556
  def negative?: () -> bot
537
557
 
538
- def nonzero?: () -> self?
539
-
540
558
  # <!--
541
559
  # rdoc-file=complex.c
542
560
  # - numerator -> new_complex
@@ -594,9 +612,9 @@ class Complex < Numeric
594
612
 
595
613
  # <!--
596
614
  # rdoc-file=complex.c
597
- # - complex / numeric -> new_complex
615
+ # - self / other -> complex
598
616
  # -->
599
- # Returns the quotient of `self` and `numeric`:
617
+ # Returns the quotient of `self` and `other`:
600
618
  #
601
619
  # Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
602
620
  # Complex.rect(900) / Complex.rect(1) # => (900+0i)
@@ -740,8 +758,6 @@ class Complex < Numeric
740
758
  #
741
759
  def to_i: () -> Integer
742
760
 
743
- alias to_int to_i
744
-
745
761
  # <!--
746
762
  # rdoc-file=complex.c
747
763
  # - to_r -> rational
@@ -774,8 +790,6 @@ class Complex < Numeric
774
790
  def to_s: () -> String
775
791
 
776
792
  def truncate: (?Integer) -> bot
777
-
778
- def zero?: () -> bool
779
793
  end
780
794
 
781
795
  # <!-- rdoc-file=complex.c -->