rbs 3.10.4 → 4.0.0

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 (267) 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 +7 -5
  5. data/.github/workflows/comments.yml +2 -2
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +16 -26
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +1 -1
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +2 -2
  12. data/.vscode/extensions.json +5 -0
  13. data/.vscode/settings.json +19 -0
  14. data/CHANGELOG.md +202 -2
  15. data/Rakefile +9 -23
  16. data/Steepfile +2 -0
  17. data/config.yml +457 -13
  18. data/core/array.rbs +218 -188
  19. data/core/basic_object.rbs +9 -8
  20. data/core/binding.rbs +0 -2
  21. data/core/builtin.rbs +2 -2
  22. data/core/class.rbs +6 -5
  23. data/core/comparable.rbs +45 -31
  24. data/core/complex.rbs +66 -55
  25. data/core/dir.rbs +57 -45
  26. data/core/encoding.rbs +6 -6
  27. data/core/enumerable.rbs +105 -91
  28. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  29. data/core/enumerator.rbs +24 -3
  30. data/core/errno.rbs +3 -2
  31. data/core/errors.rbs +31 -29
  32. data/core/exception.rbs +12 -12
  33. data/core/fiber.rbs +47 -36
  34. data/core/file.rbs +242 -169
  35. data/core/file_test.rbs +2 -2
  36. data/core/float.rbs +42 -68
  37. data/core/gc.rbs +78 -70
  38. data/core/hash.rbs +70 -60
  39. data/core/integer.rbs +32 -75
  40. data/core/io/buffer.rbs +36 -36
  41. data/core/io/wait.rbs +7 -7
  42. data/core/io.rbs +192 -146
  43. data/core/kernel.rbs +198 -147
  44. data/core/marshal.rbs +3 -3
  45. data/core/match_data.rbs +14 -12
  46. data/core/math.rbs +69 -67
  47. data/core/method.rbs +6 -8
  48. data/core/module.rbs +148 -88
  49. data/core/nil_class.rbs +4 -3
  50. data/core/numeric.rbs +53 -50
  51. data/core/object.rbs +6 -8
  52. data/core/object_space.rbs +11 -10
  53. data/core/pathname.rbs +131 -81
  54. data/core/proc.rbs +65 -34
  55. data/core/process.rbs +221 -201
  56. data/core/ractor.rbs +15 -11
  57. data/core/random.rbs +21 -3
  58. data/core/range.rbs +152 -49
  59. data/core/rational.rbs +5 -56
  60. data/core/rbs/unnamed/argf.rbs +58 -51
  61. data/core/rbs/unnamed/env_class.rbs +18 -13
  62. data/core/rbs/unnamed/main_class.rbs +123 -0
  63. data/core/rbs/unnamed/random.rbs +7 -116
  64. data/core/regexp.rbs +236 -197
  65. data/core/ruby.rbs +1 -1
  66. data/core/ruby_vm.rbs +32 -30
  67. data/core/rubygems/config_file.rbs +5 -5
  68. data/core/rubygems/errors.rbs +1 -1
  69. data/core/rubygems/requirement.rbs +5 -5
  70. data/core/rubygems/rubygems.rbs +5 -3
  71. data/core/set.rbs +17 -16
  72. data/core/signal.rbs +2 -2
  73. data/core/string.rbs +318 -298
  74. data/core/struct.rbs +26 -25
  75. data/core/symbol.rbs +25 -24
  76. data/core/thread.rbs +40 -41
  77. data/core/time.rbs +47 -42
  78. data/core/trace_point.rbs +34 -31
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +10 -10
  81. data/core/warning.rbs +7 -7
  82. data/docs/collection.md +1 -1
  83. data/docs/config.md +171 -0
  84. data/docs/inline.md +576 -0
  85. data/docs/syntax.md +46 -16
  86. data/docs/type_fingerprint.md +21 -0
  87. data/exe/rbs +1 -1
  88. data/ext/rbs_extension/ast_translation.c +595 -98
  89. data/ext/rbs_extension/class_constants.c +30 -0
  90. data/ext/rbs_extension/class_constants.h +15 -0
  91. data/ext/rbs_extension/legacy_location.c +30 -53
  92. data/ext/rbs_extension/legacy_location.h +37 -0
  93. data/ext/rbs_extension/main.c +125 -24
  94. data/include/rbs/ast.h +485 -150
  95. data/include/rbs/lexer.h +11 -4
  96. data/include/rbs/location.h +25 -44
  97. data/include/rbs/parser.h +20 -2
  98. data/include/rbs/util/rbs_constant_pool.h +0 -3
  99. data/include/rbs.h +8 -0
  100. data/lib/rbs/ast/annotation.rb +1 -1
  101. data/lib/rbs/ast/comment.rb +1 -1
  102. data/lib/rbs/ast/declarations.rb +10 -10
  103. data/lib/rbs/ast/members.rb +14 -14
  104. data/lib/rbs/ast/ruby/annotations.rb +409 -0
  105. data/lib/rbs/ast/ruby/comment_block.rb +245 -0
  106. data/lib/rbs/ast/ruby/declarations.rb +281 -0
  107. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  108. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  109. data/lib/rbs/ast/ruby/members.rb +723 -0
  110. data/lib/rbs/ast/type_param.rb +24 -4
  111. data/lib/rbs/buffer.rb +105 -20
  112. data/lib/rbs/cli/diff.rb +16 -15
  113. data/lib/rbs/cli/validate.rb +62 -125
  114. data/lib/rbs/cli.rb +55 -23
  115. data/lib/rbs/collection/config/lockfile_generator.rb +8 -4
  116. data/lib/rbs/collection/sources/git.rb +1 -0
  117. data/lib/rbs/collection.rb +0 -1
  118. data/lib/rbs/definition.rb +6 -1
  119. data/lib/rbs/definition_builder/ancestor_builder.rb +119 -63
  120. data/lib/rbs/definition_builder/method_builder.rb +65 -30
  121. data/lib/rbs/definition_builder.rb +177 -20
  122. data/lib/rbs/diff.rb +7 -1
  123. data/lib/rbs/environment/class_entry.rb +69 -0
  124. data/lib/rbs/environment/module_entry.rb +66 -0
  125. data/lib/rbs/environment.rb +338 -155
  126. data/lib/rbs/environment_loader.rb +2 -2
  127. data/lib/rbs/errors.rb +30 -20
  128. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  129. data/lib/rbs/inline_parser.rb +542 -0
  130. data/lib/rbs/location_aux.rb +36 -4
  131. data/lib/rbs/locator.rb +5 -1
  132. data/lib/rbs/method_type.rb +5 -3
  133. data/lib/rbs/namespace.rb +0 -7
  134. data/lib/rbs/parser_aux.rb +31 -8
  135. data/lib/rbs/prototype/helpers.rb +57 -0
  136. data/lib/rbs/prototype/rb.rb +3 -28
  137. data/lib/rbs/prototype/rbi.rb +3 -20
  138. data/lib/rbs/prototype/runtime.rb +10 -2
  139. data/lib/rbs/resolver/type_name_resolver.rb +0 -8
  140. data/lib/rbs/source.rb +99 -0
  141. data/lib/rbs/subtractor.rb +4 -3
  142. data/lib/rbs/test/type_check.rb +5 -2
  143. data/lib/rbs/type_name.rb +1 -8
  144. data/lib/rbs/types.rb +88 -78
  145. data/lib/rbs/unit_test/convertibles.rb +1 -0
  146. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  147. data/lib/rbs/validator.rb +2 -2
  148. data/lib/rbs/version.rb +1 -1
  149. data/lib/rbs.rb +12 -1
  150. data/rbs.gemspec +3 -2
  151. data/rust/.gitignore +1 -0
  152. data/rust/Cargo.lock +378 -0
  153. data/rust/Cargo.toml +7 -0
  154. data/rust/ruby-rbs/Cargo.toml +22 -0
  155. data/rust/ruby-rbs/build.rs +764 -0
  156. data/rust/ruby-rbs/examples/locations.rs +60 -0
  157. data/rust/ruby-rbs/src/lib.rs +1 -0
  158. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  159. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  160. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  161. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  162. data/rust/ruby-rbs-sys/build.rs +204 -0
  163. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  164. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  165. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  166. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  167. data/schema/typeParam.json +17 -1
  168. data/sig/ancestor_builder.rbs +1 -1
  169. data/sig/ast/ruby/annotations.rbs +421 -0
  170. data/sig/ast/ruby/comment_block.rbs +127 -0
  171. data/sig/ast/ruby/declarations.rbs +158 -0
  172. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  173. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  174. data/sig/ast/ruby/members.rbs +178 -0
  175. data/sig/buffer.rbs +63 -5
  176. data/sig/cli/diff.rbs +5 -11
  177. data/sig/cli/validate.rbs +12 -8
  178. data/sig/cli.rbs +18 -18
  179. data/sig/definition.rbs +6 -0
  180. data/sig/definition_builder.rbs +3 -1
  181. data/sig/environment/class_entry.rbs +50 -0
  182. data/sig/environment/module_entry.rbs +50 -0
  183. data/sig/environment.rbs +37 -81
  184. data/sig/errors.rbs +26 -20
  185. data/sig/inline_parser/comment_association.rbs +71 -0
  186. data/sig/inline_parser.rbs +124 -0
  187. data/sig/location.rbs +32 -7
  188. data/sig/locator.rbs +0 -2
  189. data/sig/method_builder.rbs +9 -4
  190. data/sig/namespace.rbs +0 -5
  191. data/sig/parser.rbs +47 -13
  192. data/sig/prototype/helpers.rbs +2 -0
  193. data/sig/resolver/type_name_resolver.rbs +0 -3
  194. data/sig/source.rbs +48 -0
  195. data/sig/type_param.rbs +13 -8
  196. data/sig/typename.rbs +0 -5
  197. data/sig/types.rbs +6 -7
  198. data/sig/unit_test/spy.rbs +0 -8
  199. data/sig/unit_test/type_assertions.rbs +11 -0
  200. data/src/ast.c +491 -143
  201. data/src/lexer.c +1552 -1314
  202. data/src/lexer.re +7 -0
  203. data/src/lexstate.c +8 -1
  204. data/src/location.c +8 -48
  205. data/src/parser.c +1107 -409
  206. data/src/util/rbs_constant_pool.c +0 -4
  207. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  208. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  209. data/stdlib/coverage/0/coverage.rbs +4 -3
  210. data/stdlib/date/0/date.rbs +33 -28
  211. data/stdlib/date/0/date_time.rbs +24 -23
  212. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  213. data/stdlib/digest/0/digest.rbs +110 -0
  214. data/stdlib/erb/0/erb.rbs +64 -53
  215. data/stdlib/etc/0/etc.rbs +55 -50
  216. data/stdlib/fileutils/0/fileutils.rbs +140 -126
  217. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  218. data/stdlib/io-console/0/io-console.rbs +2 -2
  219. data/stdlib/json/0/json.rbs +158 -131
  220. data/stdlib/monitor/0/monitor.rbs +3 -3
  221. data/stdlib/net-http/0/net-http.rbs +159 -134
  222. data/stdlib/objspace/0/objspace.rbs +8 -30
  223. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  224. data/stdlib/open3/0/open3.rbs +469 -10
  225. data/stdlib/openssl/0/openssl.rbs +144 -129
  226. data/stdlib/optparse/0/optparse.rbs +23 -14
  227. data/stdlib/pathname/0/pathname.rbs +2 -2
  228. data/stdlib/pp/0/pp.rbs +9 -8
  229. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  230. data/stdlib/pstore/0/pstore.rbs +35 -30
  231. data/stdlib/psych/0/psych.rbs +62 -9
  232. data/stdlib/psych/0/store.rbs +2 -4
  233. data/stdlib/pty/0/pty.rbs +9 -6
  234. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  235. data/stdlib/rdoc/0/code_object.rbs +2 -1
  236. data/stdlib/rdoc/0/parser.rbs +1 -1
  237. data/stdlib/rdoc/0/store.rbs +1 -1
  238. data/stdlib/ripper/0/ripper.rbs +20 -17
  239. data/stdlib/securerandom/0/manifest.yaml +2 -0
  240. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  241. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  242. data/stdlib/socket/0/addrinfo.rbs +9 -9
  243. data/stdlib/socket/0/basic_socket.rbs +3 -3
  244. data/stdlib/socket/0/ip_socket.rbs +10 -8
  245. data/stdlib/socket/0/socket.rbs +10 -9
  246. data/stdlib/socket/0/tcp_server.rbs +1 -1
  247. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  248. data/stdlib/socket/0/udp_socket.rbs +1 -1
  249. data/stdlib/socket/0/unix_server.rbs +1 -1
  250. data/stdlib/stringio/0/stringio.rbs +55 -54
  251. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  252. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  253. data/stdlib/time/0/time.rbs +7 -5
  254. data/stdlib/tsort/0/tsort.rbs +7 -6
  255. data/stdlib/uri/0/common.rbs +31 -18
  256. data/stdlib/uri/0/file.rbs +2 -2
  257. data/stdlib/uri/0/generic.rbs +9 -2
  258. data/stdlib/uri/0/http.rbs +2 -2
  259. data/stdlib/uri/0/ldap.rbs +2 -2
  260. data/stdlib/uri/0/mailto.rbs +3 -3
  261. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  262. data/stdlib/zlib/0/deflate.rbs +4 -3
  263. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  264. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  265. data/stdlib/zlib/0/inflate.rbs +1 -1
  266. data/stdlib/zlib/0/need_dict.rbs +1 -1
  267. metadata +66 -3
data/core/enumerable.rbs CHANGED
@@ -16,8 +16,8 @@
16
16
  # These methods return information about the Enumerable other than the elements
17
17
  # themselves:
18
18
  #
19
- # * #member? (aliased as #include?): Returns `true` if `self == object`,
20
- # `false` otherwise.
19
+ # * #member? (aliased as #include?): Returns `true` if <code>self ==
20
+ # object</code>, `false` otherwise.
21
21
  # * #all?: Returns `true` if all elements meet a specified criterion; `false`
22
22
  # otherwise.
23
23
  # * #any?: Returns `true` if any element meets a specified criterion; `false`
@@ -35,7 +35,7 @@
35
35
  #
36
36
  # These methods return entries from the Enumerable, without modifying it:
37
37
  #
38
- # *Leading, trailing, or all elements*:
38
+ # <em>Leading, trailing, or all elements</em>:
39
39
  #
40
40
  # * #to_a (aliased as #entries): Returns all elements.
41
41
  # * #first: Returns the first element or leading elements.
@@ -47,9 +47,9 @@
47
47
  # *Minimum and maximum value elements*:
48
48
  #
49
49
  # * #min: Returns the elements whose values are smallest among the elements,
50
- # as determined by `#<=>` or a given block.
50
+ # as determined by <code>#<=></code> or a given block.
51
51
  # * #max: Returns the elements whose values are largest among the elements, as
52
- # determined by `#<=>` or a given block.
52
+ # determined by <code>#<=></code> or a given block.
53
53
  # * #minmax: Returns a 2-element Array containing the smallest and largest
54
54
  # elements.
55
55
  # * #min_by: Returns the smallest element, as determined by the given block.
@@ -57,7 +57,7 @@
57
57
  # * #minmax_by: Returns the smallest and largest elements, as determined by
58
58
  # the given block.
59
59
  #
60
- # *Groups, slices, and partitions*:
60
+ # <em>Groups, slices, and partitions</em>:
61
61
  #
62
62
  # * #group_by: Returns a Hash that partitions the elements into groups.
63
63
  # * #partition: Returns elements partitioned into two new Arrays, as
@@ -89,7 +89,8 @@
89
89
  #
90
90
  # These methods return elements in sorted order:
91
91
  #
92
- # * #sort: Returns the elements, sorted by `#<=>` or the given block.
92
+ # * #sort: Returns the elements, sorted by <code>#<=></code> or the given
93
+ # block.
93
94
  # * #sort_by: Returns the elements, sorted by the given block.
94
95
  #
95
96
  # ### Methods for Iterating
@@ -118,7 +119,7 @@
118
119
  # returned by a given block.
119
120
  # * #inject (aliased as #reduce): Returns the object formed by combining all
120
121
  # elements.
121
- # * #sum: Returns the sum of the elements, using method `+`.
122
+ # * #sum: Returns the sum of the elements, using method <code>+</code>.
122
123
  # * #zip: Combines each element with elements from other enumerables; returns
123
124
  # the n-tuples or calls the block with each.
124
125
  # * #cycle: Calls the block with each element, cycling repeatedly.
@@ -131,8 +132,9 @@
131
132
  #
132
133
  # include Enumerable
133
134
  #
134
- # * Implement method `#each` which must yield successive elements of the
135
- # collection. The method will be called by almost any Enumerable method.
135
+ # * Implement method <code>#each</code> which must yield successive elements
136
+ # of the collection. The method will be called by almost any Enumerable
137
+ # method.
136
138
  #
137
139
  # Example:
138
140
  #
@@ -173,13 +175,15 @@
173
175
  # * CSV::Row
174
176
  # * Set
175
177
  #
176
- # Virtually all methods in Enumerable call method `#each` in the including
177
- # class:
178
+ # Virtually all methods in Enumerable call method <code>#each</code> in the
179
+ # including class:
178
180
  #
179
- # * `Hash#each` yields the next key-value pair as a 2-element Array.
180
- # * `Struct#each` yields the next name-value pair as a 2-element Array.
181
- # * For the other classes above, `#each` yields the next object from the
182
- # collection.
181
+ # * <code>Hash#each</code> yields the next key-value pair as a 2-element
182
+ # Array.
183
+ # * <code>Struct#each</code> yields the next name-value pair as a 2-element
184
+ # Array.
185
+ # * For the other classes above, <code>#each</code> yields the next object
186
+ # from the collection.
183
187
  #
184
188
  # ## About the Examples
185
189
  #
@@ -199,7 +203,7 @@
199
203
  # ### #size
200
204
  #
201
205
  # Enumerator has a #size method. It uses the size function argument passed to
202
- # `Enumerator.new`.
206
+ # <code>Enumerator.new</code>.
203
207
  #
204
208
  # e = Enumerator.new(-> { 3 }) {|y| p y; y.yield :a; y.yield :b; y.yield :c; :z }
205
209
  # p e.size #=> 3
@@ -216,10 +220,10 @@
216
220
  # (i.e., the number of times Enumerator::Yielder#yield is called). In the above
217
221
  # example, the block calls #yield three times, and the size function, +-> { 3
218
222
  # }+, returns 3 accordingly. The result of the size function can be an integer,
219
- # `Float::INFINITY`, or `nil`. An integer means the exact number of times #yield
220
- # will be called, as shown above. `Float::INFINITY` indicates an infinite number
221
- # of #yield calls. `nil` means the number of #yield calls is difficult or
222
- # impossible to determine.
223
+ # <code>Float::INFINITY</code>, or `nil`. An integer means the exact number of
224
+ # times #yield will be called, as shown above. <code>Float::INFINITY</code>
225
+ # indicates an infinite number of #yield calls. `nil` means the number of #yield
226
+ # calls is difficult or impossible to determine.
223
227
  #
224
228
  # Many iteration methods return an Enumerator object with an appropriate size
225
229
  # function if no block is given.
@@ -238,7 +242,7 @@
238
242
  # element:
239
243
  #
240
244
  # * If the #begin element is an Integer, the #size method returns an Integer
241
- # or `Float::INFINITY`.
245
+ # or <code>Float::INFINITY</code>.
242
246
  # * If the #begin element is an object with a #succ method (other than
243
247
  # Integer), #size returns `nil`. (Computing the size would require
244
248
  # repeatedly calling #succ, which may be too slow.)
@@ -268,6 +272,11 @@
268
272
  # file, not the number of lines.
269
273
  #
270
274
  module Enumerable[unchecked out Elem] : _Each[Elem]
275
+ %a{private}
276
+ interface _Pattern
277
+ def ===: (untyped) -> bool
278
+ end
279
+
271
280
  # <!--
272
281
  # rdoc-file=enum.c
273
282
  # - all? -> true or false
@@ -287,7 +296,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
287
296
  # [].all? # => true
288
297
  #
289
298
  # With argument `pattern` and no block, returns whether for each element
290
- # `element`, `pattern === element`:
299
+ # `element`, <code>pattern === element</code>:
291
300
  #
292
301
  # (1..4).all?(Integer) # => true
293
302
  # (1..4).all?(Numeric) # => true
@@ -310,6 +319,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
310
319
  # Related: #any?, #none? #one?.
311
320
  #
312
321
  def all?: () -> bool
322
+ | (_Pattern) -> bool
313
323
  | () { (Elem) -> boolish } -> bool
314
324
 
315
325
  # <!--
@@ -330,7 +340,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
330
340
  # [].any? # => false
331
341
  #
332
342
  # With argument `pattern` and no block, returns whether for any element
333
- # `element`, `pattern === element`:
343
+ # `element`, <code>pattern === element</code>:
334
344
  #
335
345
  # [nil, false, 0].any?(Integer) # => true
336
346
  # [nil, false, 0].any?(Numeric) # => true
@@ -353,6 +363,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
353
363
  # Related: #all?, #none?, #one?.
354
364
  #
355
365
  def any?: () -> bool
366
+ | (_Pattern) -> bool
356
367
  | () { (Elem) -> boolish } -> bool
357
368
 
358
369
  # <!--
@@ -416,8 +427,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
416
427
  # [0, 1, 2].count # => 3
417
428
  # {foo: 0, bar: 1, baz: 2}.count # => 3
418
429
  #
419
- # With argument `object` given, returns the number of elements that are `==` to
420
- # `object`:
430
+ # With argument `object` given, returns the number of elements that are
431
+ # <code>==</code> to `object`:
421
432
  #
422
433
  # [0, 1, 2, 1].count(1) # => 2
423
434
  #
@@ -555,8 +566,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
555
566
  # - each_with_index(*args) {|element, i| ..... } -> self
556
567
  # - each_with_index(*args) -> enumerator
557
568
  # -->
558
- # Invoke `self.each` with `*args`. With a block given, the block receives each
559
- # element and its index; returns `self`:
569
+ # Invoke <code>self.each</code> with <code>*args</code>. With a block given, the
570
+ # block receives each element and its index; returns `self`:
560
571
  #
561
572
  # h = {}
562
573
  # (1..4).each_with_index {|element, i| h[element] = i } # => 1..4
@@ -673,7 +684,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
673
684
  # `nil` if no such element is found.
674
685
  #
675
686
  # With argument `object` given, returns the index of the first element that is
676
- # `==` `object`:
687
+ # <code>==</code> `object`:
677
688
  #
678
689
  # ['a', 'b', 'c', 'b'].find_index('b') # => 1
679
690
  #
@@ -724,7 +735,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
724
735
  # pattern.
725
736
  #
726
737
  # With no block given, returns an array containing each element for which
727
- # `pattern === element` is `true`:
738
+ # <code>pattern === element</code> is `true`:
728
739
  #
729
740
  # a = ['foo', 'bar', 'car', 'moo']
730
741
  # a.grep(/ar/) # => ["bar", "car"]
@@ -747,11 +758,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
747
758
  # - grep_v(pattern) -> array
748
759
  # - grep_v(pattern) {|element| ... } -> array
749
760
  # -->
750
- # Returns an array of objects based on elements of `self` that *don't* match the
751
- # given pattern.
761
+ # Returns an array of objects based on elements of `self` that <em>don't</em>
762
+ # match the given pattern.
752
763
  #
753
764
  # With no block given, returns an array containing each element for which
754
- # `pattern === element` is `false`:
765
+ # <code>pattern === element</code> is `false`:
755
766
  #
756
767
  # a = ['foo', 'bar', 'car', 'moo']
757
768
  # a.grep_v(/ar/) # => ["foo", "moo"]
@@ -794,7 +805,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
794
805
  | () -> ::Enumerator[Elem, ::Array[Elem]]
795
806
 
796
807
  # <!-- rdoc-file=enum.c -->
797
- # Returns whether for any element `object == element`:
808
+ # Returns whether for any element <code>object == element</code>:
798
809
  #
799
810
  # (1..4).include?(2) # => true
800
811
  # (1..4).include?(5) # => false
@@ -805,7 +816,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
805
816
  # {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
806
817
  # {foo: 0, bar: 1, baz: 2}.include?(0) # => false
807
818
  #
808
- def include?: (Elem arg0) -> bool
819
+ def include?: (top arg0) -> bool
809
820
 
810
821
  # <!--
811
822
  # rdoc-file=enum.c
@@ -852,13 +863,13 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
852
863
  # product #=> 24
853
864
  #
854
865
  # When this runs, the block is first called with `1` (the initial value) and `2`
855
- # (the first element of the array). The block returns `1*2`, so on the next
856
- # iteration the block is called with `2` (the previous result) and `3`. The
857
- # block returns `6`, and is called one last time with `6` and `4`. The result of
858
- # the block, `24` becomes the value returned by `inject`. This code returns the
859
- # product of the elements in the enumerable.
866
+ # (the first element of the array). The block returns <code>1*2</code>, so on
867
+ # the next iteration the block is called with `2` (the previous result) and `3`.
868
+ # The block returns `6`, and is called one last time with `6` and `4`. The
869
+ # result of the block, `24` becomes the value returned by `inject`. This code
870
+ # returns the product of the elements in the enumerable.
860
871
  #
861
- # **First Shortcut: Default Initial value**
872
+ # <strong>First Shortcut: Default Initial value</strong>
862
873
  #
863
874
  # In the case of the previous example, the initial value, `1`, wasn't really
864
875
  # necessary: the calculation of the product of a list of numbers is
@@ -895,7 +906,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
895
906
  # Note that the last line of the block is just the word `counts`. This ensures
896
907
  # the return value of the block is the result that's being calculated.
897
908
  #
898
- # **Second Shortcut: a Reducer function**
909
+ # <strong>Second Shortcut: a Reducer function</strong>
899
910
  #
900
911
  # A *reducer function* is a function that takes a partial result and the next
901
912
  # value, returning the next partial result. The block that is given to `inject`
@@ -940,11 +951,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
940
951
  # position = "nnneesw".chars.reduce(Turtle.new, :move)
941
952
  # position #=>> #<Turtle:0x00000001052f4698 @y=2, @x=1>
942
953
  #
943
- # **Third Shortcut: Reducer With no Initial Value**
954
+ # <strong>Third Shortcut: Reducer With no Initial Value</strong>
944
955
  #
945
956
  # If your reducer returns a value that it can accept as a parameter, then you
946
- # don't have to pass in an initial value. Here `:*` is the name of the *times*
947
- # function:
957
+ # don't have to pass in an initial value. Here <code>:*</code> is the name of
958
+ # the *times* function:
948
959
  #
949
960
  # product = [ 2, 3, 4 ].inject(:*)
950
961
  # product # => 24
@@ -975,7 +986,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
975
986
  # The ordering of equal elements is indeterminate and may be unstable.
976
987
  #
977
988
  # With no argument and no block, returns the maximum element, using the
978
- # elements' own method `#<=>` for comparison:
989
+ # elements' own method <code>#<=></code> for comparison:
979
990
  #
980
991
  # (1..4).max # => 4
981
992
  # (-4..-1).max # => -1
@@ -995,9 +1006,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
995
1006
  # With a block given, the block determines the maximum elements. The block is
996
1007
  # called with two elements `a` and `b`, and must return:
997
1008
  #
998
- # * A negative integer if `a < b`.
999
- # * Zero if `a == b`.
1000
- # * A positive integer if `a > b`.
1009
+ # * A negative integer if <code>a < b</code>.
1010
+ # * Zero if <code>a == b</code>.
1011
+ # * A positive integer if <code>a > b</code>.
1001
1012
  #
1002
1013
  # With a block given and no argument, returns the maximum element as determined
1003
1014
  # by the block:
@@ -1073,7 +1084,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1073
1084
  # The ordering of equal elements is indeterminate and may be unstable.
1074
1085
  #
1075
1086
  # With no argument and no block, returns the minimum element, using the
1076
- # elements' own method `#<=>` for comparison:
1087
+ # elements' own method <code>#<=></code> for comparison:
1077
1088
  #
1078
1089
  # (1..4).min # => 1
1079
1090
  # (-4..-1).min # => -4
@@ -1093,9 +1104,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1093
1104
  # With a block given, the block determines the minimum elements. The block is
1094
1105
  # called with two elements `a` and `b`, and must return:
1095
1106
  #
1096
- # * A negative integer if `a < b`.
1097
- # * Zero if `a == b`.
1098
- # * A positive integer if `a > b`.
1107
+ # * A negative integer if <code>a < b</code>.
1108
+ # * Zero if <code>a == b</code>.
1109
+ # * A positive integer if <code>a > b</code>.
1099
1110
  #
1100
1111
  # With a block given and no argument, returns the minimum element as determined
1101
1112
  # by the block:
@@ -1170,7 +1181,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1170
1181
  # indeterminate and may be unstable.
1171
1182
  #
1172
1183
  # With no argument and no block, returns the minimum and maximum elements, using
1173
- # the elements' own method `#<=>` for comparison:
1184
+ # the elements' own method <code>#<=></code> for comparison:
1174
1185
  #
1175
1186
  # (1..4).minmax # => [1, 4]
1176
1187
  # (-4..-1).minmax # => [-4, -1]
@@ -1233,7 +1244,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1233
1244
  # [].none? # => true
1234
1245
  #
1235
1246
  # With argument `pattern` and no block, returns whether for no element
1236
- # `element`, `pattern === element`:
1247
+ # `element`, <code>pattern === element</code>:
1237
1248
  #
1238
1249
  # [nil, false, 1.1].none?(Integer) # => true
1239
1250
  # %w[bar baz bat bam].none?(/m/) # => false
@@ -1254,6 +1265,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1254
1265
  # Related: #one?, #all?, #any?.
1255
1266
  #
1256
1267
  def none?: () -> bool
1268
+ | (_Pattern) -> bool
1257
1269
  | () { (Elem) -> boolish } -> bool
1258
1270
 
1259
1271
  # <!--
@@ -1274,7 +1286,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1274
1286
  # [].one? # => false
1275
1287
  #
1276
1288
  # With argument `pattern` and no block, returns whether for exactly one element
1277
- # `element`, `pattern === element`:
1289
+ # `element`, <code>pattern === element</code>:
1278
1290
  #
1279
1291
  # [nil, false, 0].one?(Integer) # => true
1280
1292
  # [nil, false, 0].one?(Numeric) # => true
@@ -1297,6 +1309,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1297
1309
  # Related: #none?, #all?, #any?.
1298
1310
  #
1299
1311
  def one?: () -> bool
1312
+ | (_Pattern) -> bool
1300
1313
  | () { (Elem) -> boolish } -> bool
1301
1314
 
1302
1315
  # <!--
@@ -1384,7 +1397,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1384
1397
  # Returns an array containing the sorted elements of `self`. The ordering of
1385
1398
  # equal elements is indeterminate and may be unstable.
1386
1399
  #
1387
- # With no block given, the sort compares using the elements' own method `#<=>`:
1400
+ # With no block given, the sort compares using the elements' own method
1401
+ # <code>#<=></code>:
1388
1402
  #
1389
1403
  # %w[b c a d].sort # => ["a", "b", "c", "d"]
1390
1404
  # {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]]
@@ -1392,9 +1406,9 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1392
1406
  # With a block given, comparisons in the block determine the ordering. The block
1393
1407
  # is called with two elements `a` and `b`, and must return:
1394
1408
  #
1395
- # * A negative integer if `a < b`.
1396
- # * Zero if `a == b`.
1397
- # * A positive integer if `a > b`.
1409
+ # * A negative integer if <code>a < b</code>.
1410
+ # * Zero if <code>a == b</code>.
1411
+ # * A positive integer if <code>a > b</code>.
1398
1412
  #
1399
1413
  # Examples:
1400
1414
  #
@@ -1442,7 +1456,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1442
1456
  # b.report("Sort by") { a.sort_by { |a| a } }
1443
1457
  # end
1444
1458
  #
1445
- # *produces:*
1459
+ # <em>produces:</em>
1446
1460
  #
1447
1461
  # user system total real
1448
1462
  # Sort 0.180000 0.000000 0.180000 ( 0.175469)
@@ -1638,7 +1652,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1638
1652
  # rdoc-file=enum.c
1639
1653
  # - include?(object) -> true or false
1640
1654
  # -->
1641
- # Returns whether for any element `object == element`:
1655
+ # Returns whether for any element <code>object == element</code>:
1642
1656
  #
1643
1657
  # (1..4).include?(2) # => true
1644
1658
  # (1..4).include?(5) # => false
@@ -1649,7 +1663,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1649
1663
  # {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
1650
1664
  # {foo: 0, bar: 1, baz: 2}.include?(0) # => false
1651
1665
  #
1652
- def member?: (Elem arg0) -> bool
1666
+ def member?: (top arg0) -> bool
1653
1667
 
1654
1668
  # <!-- rdoc-file=enum.c -->
1655
1669
  # Returns the result of applying a reducer to an initial value and the first
@@ -1690,13 +1704,13 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1690
1704
  # product #=> 24
1691
1705
  #
1692
1706
  # When this runs, the block is first called with `1` (the initial value) and `2`
1693
- # (the first element of the array). The block returns `1*2`, so on the next
1694
- # iteration the block is called with `2` (the previous result) and `3`. The
1695
- # block returns `6`, and is called one last time with `6` and `4`. The result of
1696
- # the block, `24` becomes the value returned by `inject`. This code returns the
1697
- # product of the elements in the enumerable.
1707
+ # (the first element of the array). The block returns <code>1*2</code>, so on
1708
+ # the next iteration the block is called with `2` (the previous result) and `3`.
1709
+ # The block returns `6`, and is called one last time with `6` and `4`. The
1710
+ # result of the block, `24` becomes the value returned by `inject`. This code
1711
+ # returns the product of the elements in the enumerable.
1698
1712
  #
1699
- # **First Shortcut: Default Initial value**
1713
+ # <strong>First Shortcut: Default Initial value</strong>
1700
1714
  #
1701
1715
  # In the case of the previous example, the initial value, `1`, wasn't really
1702
1716
  # necessary: the calculation of the product of a list of numbers is
@@ -1733,7 +1747,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1733
1747
  # Note that the last line of the block is just the word `counts`. This ensures
1734
1748
  # the return value of the block is the result that's being calculated.
1735
1749
  #
1736
- # **Second Shortcut: a Reducer function**
1750
+ # <strong>Second Shortcut: a Reducer function</strong>
1737
1751
  #
1738
1752
  # A *reducer function* is a function that takes a partial result and the next
1739
1753
  # value, returning the next partial result. The block that is given to `inject`
@@ -1778,11 +1792,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1778
1792
  # position = "nnneesw".chars.reduce(Turtle.new, :move)
1779
1793
  # position #=>> #<Turtle:0x00000001052f4698 @y=2, @x=1>
1780
1794
  #
1781
- # **Third Shortcut: Reducer With no Initial Value**
1795
+ # <strong>Third Shortcut: Reducer With no Initial Value</strong>
1782
1796
  #
1783
1797
  # If your reducer returns a value that it can accept as a parameter, then you
1784
- # don't have to pass in an initial value. Here `:*` is the name of the *times*
1785
- # function:
1798
+ # don't have to pass in an initial value. Here <code>:*</code> is the name of
1799
+ # the *times* function:
1786
1800
  #
1787
1801
  # product = [ 2, 3, 4 ].inject(:*)
1788
1802
  # product # => 24
@@ -1845,7 +1859,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1845
1859
  # - uniq {|element| ... } -> array
1846
1860
  # -->
1847
1861
  # With no block, returns a new array containing only unique elements; the array
1848
- # has no two elements `e0` and `e1` such that `e0.eql?(e1)`:
1862
+ # has no two elements `e0` and `e1` such that <code>e0.eql?(e1)</code>:
1849
1863
  #
1850
1864
  # %w[a b c c b a a b c].uniq # => ["a", "b", "c"]
1851
1865
  # [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2]
@@ -1872,12 +1886,12 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1872
1886
  # (1..100).sum(1) # => 5051
1873
1887
  # ('a'..'d').sum('foo') # => "fooabcd"
1874
1888
  #
1875
- # Generally, the sum is computed using methods `+` and `each`; for performance
1876
- # optimizations, those methods may not be used, and so any redefinition of those
1877
- # methods may not have effect here.
1889
+ # Generally, the sum is computed using methods <code>+</code> and `each`; for
1890
+ # performance optimizations, those methods may not be used, and so any
1891
+ # redefinition of those methods may not have effect here.
1878
1892
  #
1879
1893
  # One such optimization: When possible, computes using Gauss's summation formula
1880
- # *n(n+1)/2*:
1894
+ # <em>n(n+1)/2</em>:
1881
1895
  #
1882
1896
  # 100 * (100 + 1) / 2 # => 5050
1883
1897
  #
@@ -2016,8 +2030,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2016
2030
  # - zip(*other_enums) {|array| ... } -> nil
2017
2031
  # -->
2018
2032
  # With no block given, returns a new array `new_array` of size self.size whose
2019
- # elements are arrays. Each nested array `new_array[n]` is of size
2020
- # `other_enums.size+1`, and contains:
2033
+ # elements are arrays. Each nested array <code>new_array[n]</code> is of size
2034
+ # <code>other_enums.size+1</code>, and contains:
2021
2035
  #
2022
2036
  # * The `n`-th element of self.
2023
2037
  # * The `n`-th element of each of the `other_enums`.
@@ -2041,8 +2055,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2041
2055
  # # [[:baz, 2], [:gaz, 5], [:haz, 8]]
2042
2056
  # # ]
2043
2057
  #
2044
- # If any enumerable in other_enums is smaller than self, fills to `self.size`
2045
- # with `nil`:
2058
+ # If any enumerable in other_enums is smaller than self, fills to
2059
+ # <code>self.size</code> with `nil`:
2046
2060
  #
2047
2061
  # a = [:a0, :a1, :a2, :a3]
2048
2062
  # b = [:b0, :b1, :b2]
@@ -2126,8 +2140,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2126
2140
  # ["E", 8736]
2127
2141
  # ["F", 6860]
2128
2142
  #
2129
- # You can use the special symbol `:_alone` to force an element into its own
2130
- # separate chunk:
2143
+ # You can use the special symbol <code>:_alone</code> to force an element into
2144
+ # its own separate chunk:
2131
2145
  #
2132
2146
  # a = [0, 0, 1, 1]
2133
2147
  # e = a.chunk{|i| i.even? ? :_alone : true }
@@ -2142,8 +2156,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2142
2156
  # }
2143
2157
  # }
2144
2158
  #
2145
- # You can use the special symbol `:_separator` or `nil` to force an element to
2146
- # be ignored (not included in any chunk):
2159
+ # You can use the special symbol <code>:_separator</code> or `nil` to force an
2160
+ # element to be ignored (not included in any chunk):
2147
2161
  #
2148
2162
  # a = [0, 0, -1, 1, 1]
2149
2163
  # e = a.chunk{|i| i < 0 ? :_separator : true }
@@ -2305,11 +2319,11 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2305
2319
  # Creates an enumerator for each chunked elements. The ends of chunks are
2306
2320
  # defined by *pattern* and the block.
2307
2321
  #
2308
- # If *`pattern* === *elt`* returns `true` or the block returns `true` for the
2309
- # element, the element is end of a chunk.
2322
+ # If <code>_pattern_ === _elt_</code> returns `true` or the block returns `true`
2323
+ # for the element, the element is end of a chunk.
2310
2324
  #
2311
- # The `===` and *block* is called from the first element to the last element of
2312
- # *enum*.
2325
+ # The <code>===</code> and *block* is called from the first element to the last
2326
+ # element of *enum*.
2313
2327
  #
2314
2328
  # The result enumerator yields the chunked elements as an array. So `each`
2315
2329
  # method can be called as follows:
@@ -2340,7 +2354,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2340
2354
  # -->
2341
2355
  # With argument `pattern`, returns an enumerator that uses the pattern to
2342
2356
  # partition elements into arrays ("slices"). An element begins a new slice if
2343
- # `element === pattern` (or if it is the first element).
2357
+ # <code>element === pattern</code> (or if it is the first element).
2344
2358
  #
2345
2359
  # a = %w[foo bar fop for baz fob fog bam foy]
2346
2360
  # e = a.slice_before(/ba/) # => #<Enumerator: ...>
@@ -0,0 +1,70 @@
1
+ # <!-- rdoc-file=enumerator.c -->
2
+ # Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a
3
+ # representation of sequences of numbers with common difference. Instances of
4
+ # this class can be generated by the Range#step and Numeric#step methods.
5
+ #
6
+ # The class can be used for slicing Array (see Array#slice) or custom
7
+ # collections.
8
+ #
9
+ class Enumerator::ArithmeticSequence < Enumerator[Numeric]
10
+ # <!--
11
+ # rdoc-file=enumerator.c
12
+ # - aseq.begin -> num or nil
13
+ # -->
14
+ # Returns the number that defines the first element of this arithmetic sequence.
15
+ #
16
+ def begin: () -> Numeric?
17
+
18
+ # <!--
19
+ # rdoc-file=enumerator.c
20
+ # - aseq.end -> num or nil
21
+ # -->
22
+ # Returns the number that defines the end of this arithmetic sequence.
23
+ #
24
+ def end: () -> Numeric?
25
+
26
+ # <!--
27
+ # rdoc-file=enumerator.c
28
+ # - aseq.each {|i| block } -> aseq
29
+ # - aseq.each -> aseq
30
+ # -->
31
+ #
32
+ def each: () ?{ (Numeric) -> void } -> self
33
+
34
+ # <!--
35
+ # rdoc-file=enumerator.c
36
+ # - aseq.exclude_end? -> true or false
37
+ # -->
38
+ # Returns `true` if this arithmetic sequence excludes its end value.
39
+ #
40
+ def exclude_end?: () -> bool
41
+
42
+ # <!--
43
+ # rdoc-file=enumerator.c
44
+ # - aseq.last -> num or nil
45
+ # - aseq.last(n) -> an_array
46
+ # -->
47
+ # Returns the last number in this arithmetic sequence, or an array of the last
48
+ # `n` elements.
49
+ #
50
+ def last: () -> Numeric?
51
+ | (Integer n) -> Array[Numeric]
52
+
53
+ # <!--
54
+ # rdoc-file=enumerator.c
55
+ # - aseq.size -> num or nil
56
+ # -->
57
+ # Returns the number of elements in this arithmetic sequence if it is a finite
58
+ # sequence. Otherwise, returns `nil`.
59
+ #
60
+ def size: () -> (Integer | Float)
61
+
62
+ # <!--
63
+ # rdoc-file=enumerator.c
64
+ # - aseq.step -> num
65
+ # -->
66
+ # Returns the number that defines the common difference between two adjacent
67
+ # elements in this arithmetic sequence.
68
+ #
69
+ def step: () -> Numeric
70
+ end
data/core/enumerator.rbs CHANGED
@@ -171,8 +171,9 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
171
171
  #
172
172
  # The optional `size` keyword argument specifies the size of the enumerator,
173
173
  # which can be retrieved by Enumerator#size. It can be an integer,
174
- # `Float::INFINITY`, a callable object (such as a lambda), or `nil` to indicate
175
- # unknown size. When not specified, the size defaults to `Float::INFINITY`.
174
+ # <code>Float::INFINITY</code>, a callable object (such as a lambda), or `nil`
175
+ # to indicate unknown size. When not specified, the size defaults to
176
+ # <code>Float::INFINITY</code>.
176
177
  #
177
178
  # # Infinite enumerator
178
179
  # enum = Enumerator.produce(1, size: Float::INFINITY, &:succ)
@@ -305,7 +306,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
305
306
  #
306
307
  # Iteration is defined by the given block, in which a "yielder" object, given as
307
308
  # block parameter, can be used to yield a value by calling the `yield` method
308
- # (aliased as `<<`):
309
+ # (aliased as <code><<</code>):
309
310
  #
310
311
  # fib = Enumerator.new do |y|
311
312
  # a = b = 1
@@ -490,6 +491,18 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
490
491
  #
491
492
  def size: () -> (Integer | Float)?
492
493
 
494
+ # <!--
495
+ # rdoc-file=enumerator.c
496
+ # - e + enum -> enumerator
497
+ # -->
498
+ # Returns an enumerator object generated from this enumerator and a given
499
+ # enumerable.
500
+ #
501
+ # e = (1..3).each + [4, 5]
502
+ # e.to_a #=> [1, 2, 3, 4, 5]
503
+ #
504
+ def +: [Elem2] (::_Each[Elem2]) -> ::Enumerator::Chain[Elem | Elem2]
505
+
493
506
  # <!--
494
507
  # rdoc-file=enumerator.c
495
508
  # - e.with_index(offset = 0) {|(*args), idx| ... }
@@ -620,6 +633,14 @@ class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
620
633
  # Like Enumerable#compact, but chains operation to be lazy-evaluated.
621
634
  #
622
635
  def compact: () -> Enumerator::Lazy[Elem, Return]
636
+
637
+ # <!--
638
+ # rdoc-file=enumerator.c
639
+ # - lzy.eager -> enum
640
+ # -->
641
+ # Returns a non-lazy Enumerator converted from the lazy enumerator.
642
+ #
643
+ def eager: () -> ::Enumerator[Elem, Return]
623
644
  end
624
645
 
625
646
  # <!-- rdoc-file=enumerator.c -->