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/enumerable.rbs CHANGED
@@ -114,8 +114,8 @@
114
114
  # by the block.
115
115
  # * #grep: Returns elements selected by a given object or objects returned by
116
116
  # a given block.
117
- # * #grep_v: Returns elements selected by a given object or objects returned
118
- # by a given block.
117
+ # * #grep_v: Returns elements not selected by a given object or objects
118
+ # returned by a given block.
119
119
  # * #inject (aliased as #reduce): Returns the object formed by combining all
120
120
  # elements.
121
121
  # * #sum: Returns the sum of the elements, using method `+`.
@@ -191,6 +191,82 @@
191
191
  # usage would not make sense, and so it is not shown. Example: #tally would
192
192
  # find exactly one of each Hash entry.
193
193
  #
194
+ # ## Extended Methods
195
+ #
196
+ # A Enumerable class may define extended methods. This section describes the
197
+ # standard behavior of extension methods for reference purposes.
198
+ #
199
+ # ### #size
200
+ #
201
+ # Enumerator has a #size method. It uses the size function argument passed to
202
+ # `Enumerator.new`.
203
+ #
204
+ # e = Enumerator.new(-> { 3 }) {|y| p y; y.yield :a; y.yield :b; y.yield :c; :z }
205
+ # p e.size #=> 3
206
+ # p e.next #=> :a
207
+ # p e.next #=> :b
208
+ # p e.next #=> :c
209
+ # begin
210
+ # e.next
211
+ # rescue StopIteration
212
+ # p $!.result #=> :z
213
+ # end
214
+ #
215
+ # The result of the size function should represent the number of iterations
216
+ # (i.e., the number of times Enumerator::Yielder#yield is called). In the above
217
+ # example, the block calls #yield three times, and the size function, +-> { 3
218
+ # }+, 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
+ #
224
+ # Many iteration methods return an Enumerator object with an appropriate size
225
+ # function if no block is given.
226
+ #
227
+ # Examples:
228
+ #
229
+ # ["a", "b", "c"].each.size #=> 3
230
+ # {a: "x", b: "y", c: "z"}.each.size #=> 3
231
+ # (0..20).to_a.permutation.size #=> 51090942171709440000
232
+ # loop.size #=> Float::INFINITY
233
+ # (1..100).drop_while.size #=> nil # size depends on the block's behavior
234
+ # STDIN.each.size #=> nil # cannot be computed without consuming input
235
+ # File.open("/etc/resolv.conf").each.size #=> nil # cannot be computed without reading the file
236
+ #
237
+ # The behavior of #size for Range-based enumerators depends on the #begin
238
+ # element:
239
+ #
240
+ # * If the #begin element is an Integer, the #size method returns an Integer
241
+ # or `Float::INFINITY`.
242
+ # * If the #begin element is an object with a #succ method (other than
243
+ # Integer), #size returns `nil`. (Computing the size would require
244
+ # repeatedly calling #succ, which may be too slow.)
245
+ # * If the #begin element does not have a #succ method, #size raises a
246
+ # TypeError.
247
+ #
248
+ # Examples:
249
+ #
250
+ # (10..42).each.size #=> 33
251
+ # (10..42.9).each.size #=> 33 (the #end element may be a non-integer numeric)
252
+ # (10..).each.size #=> Float::INFINITY
253
+ # ("a".."z").each.size #=> nil
254
+ # ("a"..).each.size #=> nil
255
+ # (1.0..9.0).each.size # raises TypeError (Float does not have #succ)
256
+ # (..10).each.size # raises TypeError (beginless range has nil as its #begin)
257
+ #
258
+ # The Enumerable module itself does not define a #size method. A class that
259
+ # includes Enumerable may define its own #size method. It is recommended that
260
+ # such a #size method be consistent with Enumerator#size.
261
+ #
262
+ # Array and Hash implement #size and return values consistent with
263
+ # Enumerator#size. IO and Dir do not define #size, which is also consistent
264
+ # because the corresponding enumerator's size function returns `nil`.
265
+ #
266
+ # However, it is not strictly required for a class's #size method to match
267
+ # Enumerator#size. For example, File#size returns the number of bytes in the
268
+ # file, not the number of lines.
269
+ #
194
270
  module Enumerable[unchecked out Elem] : _Each[Elem]
195
271
  # <!--
196
272
  # rdoc-file=enum.c
@@ -438,6 +514,17 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
438
514
  #
439
515
  # With no block given, returns an Enumerator.
440
516
  #
517
+ # e = (1..4).drop_while
518
+ # p e #=> #<Enumerator: 1..4:drop_while>
519
+ # i = e.next; p i; e.feed(i < 3) #=> 1
520
+ # i = e.next; p i; e.feed(i < 3) #=> 2
521
+ # i = e.next; p i; e.feed(i < 3) #=> 3
522
+ # begin
523
+ # e.next
524
+ # rescue StopIteration
525
+ # p $!.result #=> [3, 4]
526
+ # end
527
+ #
441
528
  def drop_while: () { (Elem) -> boolish } -> ::Array[Elem]
442
529
  | () -> ::Enumerator[Elem, ::Array[Elem]]
443
530
 
@@ -2040,7 +2127,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2040
2127
  # ["F", 6860]
2041
2128
  #
2042
2129
  # You can use the special symbol `:_alone` to force an element into its own
2043
- # separate chuck:
2130
+ # separate chunk:
2044
2131
  #
2045
2132
  # a = [0, 0, 1, 1]
2046
2133
  # e = a.chunk{|i| i.even? ? :_alone : true }
data/core/enumerator.rbs CHANGED
@@ -137,7 +137,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
137
137
 
138
138
  # <!--
139
139
  # rdoc-file=enumerator.c
140
- # - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
140
+ # - Enumerator.produce(initial = nil, size: nil) { |prev| block } -> enumerator
141
141
  # -->
142
142
  # Creates an infinite enumerator from any block, just called over and over. The
143
143
  # result of the previous iteration is passed to the next one. If `initial` is
@@ -169,6 +169,29 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
169
169
  # Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
170
170
  # # => ["7", "+", "38", "/", "6"]
171
171
  #
172
+ # The optional `size` keyword argument specifies the size of the enumerator,
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`.
176
+ #
177
+ # # Infinite enumerator
178
+ # enum = Enumerator.produce(1, size: Float::INFINITY, &:succ)
179
+ # enum.size # => Float::INFINITY
180
+ #
181
+ # # Finite enumerator with known/computable size
182
+ # abs_dir = File.expand_path("./baz") # => "/foo/bar/baz"
183
+ # traverser = Enumerator.produce(abs_dir, size: -> { abs_dir.count("/") + 1 }) {
184
+ # raise StopIteration if it == "/"
185
+ # File.dirname(it)
186
+ # }
187
+ # traverser.size # => 4
188
+ #
189
+ # # Finite enumerator with unknown size
190
+ # calendar = Enumerator.produce(Date.today, size: nil) {
191
+ # it.monday? ? raise(StopIteration) : it + 1
192
+ # }
193
+ # calendar.size # => nil
194
+ #
172
195
  def self.produce: [T] () { (T? prev) -> T } -> Enumerator[T, bot]
173
196
  | [T] (T initial) { (T prev) -> T } -> Enumerator[T, bot]
174
197
 
@@ -446,6 +469,25 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
446
469
  # loop.size # => Float::INFINITY
447
470
  # (1..100).drop_while.size # => nil
448
471
  #
472
+ # Note that enumerator size might be inaccurate, and should be rather treated as
473
+ # a hint. For example, there is no check that the size provided to ::new is
474
+ # accurate:
475
+ #
476
+ # e = Enumerator.new(5) { |y| 2.times { y << it} }
477
+ # e.size # => 5
478
+ # e.to_a.size # => 2
479
+ #
480
+ # Another example is an enumerator created by ::produce without a `size`
481
+ # argument. Such enumerators return `Infinity` for size, but this is inaccurate
482
+ # if the passed block raises StopIteration:
483
+ #
484
+ # e = Enumerator.produce(1) { it + 1 }
485
+ # e.size # => Infinity
486
+ #
487
+ # e = Enumerator.produce(1) { it > 3 ? raise(StopIteration) : it + 1 }
488
+ # e.size # => Infinity
489
+ # e.to_a.size # => 4
490
+ #
449
491
  def size: () -> (Integer | Float)?
450
492
 
451
493
  # <!--
data/core/errno.rbs CHANGED
@@ -38,6 +38,14 @@
38
38
  # Errno::ENOENT::Errno # => 2
39
39
  # Errno::ENOTCAPABLE::Errno # => 0
40
40
  #
41
+ # Each class in Errno can be created with optional messages:
42
+ #
43
+ # Errno::EPIPE.new # => #<Errno::EPIPE: Broken pipe>
44
+ # Errno::EPIPE.new("foo") # => #<Errno::EPIPE: Broken pipe - foo>
45
+ # Errno::EPIPE.new("foo", "here") # => #<Errno::EPIPE: Broken pipe @ here - foo>
46
+ #
47
+ # See SystemCallError.new.
48
+ #
41
49
  module Errno
42
50
  class NOERROR < SystemCallError
43
51
  Errno: 0
data/core/errors.rbs CHANGED
@@ -302,9 +302,15 @@ class NameError[T] < StandardError
302
302
  def receiver: () -> T?
303
303
  end
304
304
 
305
+ # <!-- rdoc-file=error.c -->
306
+ # Raised when matching pattern not found.
307
+ #
305
308
  class NoMatchingPatternError < StandardError
306
309
  end
307
310
 
311
+ # <!-- rdoc-file=error.c -->
312
+ # Raised when matching key not found.
313
+ #
308
314
  class NoMatchingPatternKeyError[M, K] < NoMatchingPatternError
309
315
  # <!--
310
316
  # rdoc-file=error.c
@@ -588,13 +594,34 @@ end
588
594
  class SystemCallError < StandardError
589
595
  # <!--
590
596
  # rdoc-file=error.c
591
- # - SystemCallError.new(msg, errno) -> system_call_error_subclass
597
+ # - SystemCallError.new(msg, errno = nil, func = nil) -> system_call_error_subclass
592
598
  # -->
593
599
  # If *errno* corresponds to a known system error code, constructs the
594
600
  # appropriate Errno class for that error, otherwise constructs a generic
595
601
  # SystemCallError object. The error number is subsequently available via the
596
602
  # #errno method.
597
603
  #
604
+ # If only numeric object is given, it is treated as an Integer *errno*, and
605
+ # *msg* is omitted, otherwise the first argument *msg* is used as the additional
606
+ # error message.
607
+ #
608
+ # SystemCallError.new(Errno::EPIPE::Errno)
609
+ # #=> #<Errno::EPIPE: Broken pipe>
610
+ #
611
+ # SystemCallError.new("foo")
612
+ # #=> #<SystemCallError: unknown error - foo>
613
+ #
614
+ # SystemCallError.new("foo", Errno::EPIPE::Errno)
615
+ # #=> #<Errno::EPIPE: Broken pipe - foo>
616
+ #
617
+ # If *func* is not `nil`, it is appended to the message with "` @ `".
618
+ #
619
+ # SystemCallError.new("foo", Errno::EPIPE::Errno, "here")
620
+ # #=> #<Errno::EPIPE: Broken pipe @ here - foo>
621
+ #
622
+ # A subclass of SystemCallError can also be instantiated via the `new` method of
623
+ # the subclass. See Errno.
624
+ #
598
625
  def initialize: (string msg, Integer errno) -> void
599
626
 
600
627
  # <!--
data/core/exception.rbs CHANGED
@@ -118,7 +118,7 @@ class Exception
118
118
  # # String
119
119
  # end
120
120
  #
121
- # The value returned by this method migth be adjusted when raising (see
121
+ # The value returned by this method might be adjusted when raising (see
122
122
  # Kernel#raise), or during intermediate handling by #set_backtrace.
123
123
  #
124
124
  # See also #backtrace_locations that provide the same value, as structured
@@ -447,7 +447,7 @@ class Exception
447
447
  # * If the value of keyword `order` is `:top` (the default), lists the
448
448
  # error message and the innermost backtrace entry first.
449
449
  # * If the value of keyword `order` is `:bottom`, lists the error message
450
- # the the innermost entry last.
450
+ # the innermost entry last.
451
451
  #
452
452
  # Example:
453
453
  #
data/core/fiber.rbs CHANGED
@@ -58,7 +58,7 @@
58
58
  # ## Non-blocking Fibers
59
59
  #
60
60
  # The concept of *non-blocking fiber* was introduced in Ruby 3.0. A non-blocking
61
- # fiber, when reaching a operation that would normally block the fiber (like
61
+ # fiber, when reaching an operation that would normally block the fiber (like
62
62
  # `sleep`, or wait for another process or I/O) will yield control to other
63
63
  # fibers and allow the *scheduler* to handle blocking and waking up (resuming)
64
64
  # this fiber when it can proceed.
@@ -82,7 +82,8 @@ class Fiber < Object
82
82
  # -->
83
83
  # Returns the value of the fiber storage variable identified by `key`.
84
84
  #
85
- # The `key` must be a symbol, and the value is set by Fiber#[]= or Fiber#store.
85
+ # The `key` must be a symbol, and the value is set by Fiber#[]= or
86
+ # Fiber#storage.
86
87
  #
87
88
  # See also Fiber::[]=.
88
89
  #
@@ -392,30 +393,38 @@ class Fiber < Object
392
393
 
393
394
  # <!--
394
395
  # rdoc-file=cont.c
395
- # - fiber.raise -> obj
396
- # - fiber.raise(string) -> obj
397
- # - fiber.raise(exception [, string [, array]]) -> obj
396
+ # - raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
397
+ # - raise(message = nil, cause: $!)
398
398
  # -->
399
399
  # Raises an exception in the fiber at the point at which the last `Fiber.yield`
400
- # was called. If the fiber has not been started or has already run to
401
- # completion, raises `FiberError`. If the fiber is yielding, it is resumed. If
402
- # it is transferring, it is transferred into. But if it is resuming, raises
403
- # `FiberError`.
404
- #
405
- # With no arguments, raises a `RuntimeError`. With a single `String` argument,
406
- # raises a `RuntimeError` with the string as a message. Otherwise, the first
407
- # parameter should be the name of an `Exception` class (or an object that
408
- # returns an `Exception` object when sent an `exception` message). The optional
409
- # second parameter sets the message associated with the exception, and the third
410
- # parameter is an array of callback information. Exceptions are caught by the
411
- # `rescue` clause of `begin...end` blocks.
400
+ # was called.
401
+ #
402
+ # f = Fiber.new {
403
+ # puts "Before the yield"
404
+ # Fiber.yield 1 # -- exception will be raised here
405
+ # puts "After the yield"
406
+ # }
407
+ #
408
+ # p f.resume
409
+ # f.raise "Gotcha"
410
+ #
411
+ # Output
412
+ #
413
+ # Before the first yield
414
+ # 1
415
+ # t.rb:8:in 'Fiber.yield': Gotcha (RuntimeError)
416
+ # from t.rb:8:in 'block in <main>'
417
+ #
418
+ # If the fiber has not been started or has already run to completion, raises
419
+ # `FiberError`. If the fiber is yielding, it is resumed. If it is transferring,
420
+ # it is transferred into. But if it is resuming, raises `FiberError`.
412
421
  #
413
422
  # Raises `FiberError` if called on a Fiber belonging to another `Thread`.
414
423
  #
415
- # See Kernel#raise for more information.
424
+ # See Kernel#raise for more information on arguments.
416
425
  #
417
- def raise: (?string msg) -> untyped
418
- | (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace) -> untyped
426
+ def raise: (?string msg, ?cause: Exception?) -> untyped
427
+ | (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> untyped
419
428
 
420
429
  # <!--
421
430
  # rdoc-file=cont.c
data/core/file.rbs CHANGED
@@ -1414,7 +1414,7 @@ class File < IO
1414
1414
  # rdoc-file=file.c
1415
1415
  # - File.owned?(file_name) -> true or false
1416
1416
  # -->
1417
- # Returns `true` if the named file exists and the effective used id of the
1417
+ # Returns `true` if the named file exists and the effective user id of the
1418
1418
  # calling process is the owner of the file.
1419
1419
  #
1420
1420
  # *file_name* can be an IO object.
@@ -1427,8 +1427,25 @@ class File < IO
1427
1427
  # -->
1428
1428
  # Returns the string representation of the path
1429
1429
  #
1430
- # File.path(File::NULL) #=> "/dev/null"
1431
- # File.path(Pathname.new("/tmp")) #=> "/tmp"
1430
+ # File.path(File::NULL) #=> "/dev/null"
1431
+ # File.path(Pathname.new("/tmp")) #=> "/tmp"
1432
+ #
1433
+ # If `path` is not a String:
1434
+ #
1435
+ # 1. If it has the `to_path` method, that method will be called to coerce to a
1436
+ # String.
1437
+ #
1438
+ # 2. Otherwise, or if the coerced result is not a String too, the standard
1439
+ # coersion using `to_str` method will take place on that object. (See also
1440
+ # String.try_convert)
1441
+ #
1442
+ # The coerced string must satisfy the following conditions:
1443
+ #
1444
+ # 1. It must be in an ASCII-compatible encoding; otherwise, an
1445
+ # Encoding::CompatibilityError is raised.
1446
+ #
1447
+ # 2. It must not contain the NUL character (`\0`); otherwise, an ArgumentError
1448
+ # is raised.
1432
1449
  #
1433
1450
  def self.path: (string | _ToPath path) -> String
1434
1451
 
@@ -1822,12 +1839,12 @@ class File < IO
1822
1839
  # Returns `false` if `File::LOCK_NB` is specified and the operation would have
1823
1840
  # blocked;
1824
1841
  # otherwise returns `0`.
1825
- # Constant | Lock | Effect
1826
- # ---------------|------------|--------------------------------------------------------------------------------------------------------------
1827
- # +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
1828
- # +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <tt>|</tt>.
1829
- # +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
1830
- # +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
1842
+ # Constant | Lock | Effect
1843
+ # ---------------|------------|-------------------------------------------------------------------------------------------------------
1844
+ # `File::LOCK_EX`| Exclusive | Only one process may hold an exclusive lock for `self` at a time.
1845
+ # `File::LOCK_NB`|Non-blocking|No blocking; may be combined with `File::LOCK_SH` or `File::LOCK_EX` using the bitwise OR operator `|`.
1846
+ # `File::LOCK_SH`| Shared | Multiple processes may each hold a shared lock for `self` at the same time.
1847
+ # `File::LOCK_UN`| Unlock | Remove an existing lock held by this process.
1831
1848
  # Example:
1832
1849
  # # Update a counter using an exclusive lock.
1833
1850
  # # Don't use File::WRONLY because it truncates the file.
@@ -2429,10 +2446,8 @@ class File::Stat < Object
2429
2446
 
2430
2447
  # <!--
2431
2448
  # rdoc-file=file.c
2432
- # - new(p1)
2449
+ # - File::Stat.new(file_name) -> stat
2433
2450
  # -->
2434
- # File::Stat.new(file_name) -> stat
2435
- #
2436
2451
  # Create a File::Stat object for the given file name (raising an exception if
2437
2452
  # the file doesn't exist).
2438
2453
  #
@@ -2440,16 +2455,31 @@ class File::Stat < Object
2440
2455
 
2441
2456
  # <!--
2442
2457
  # rdoc-file=file.c
2443
- # - stat <=> other_stat -> -1, 0, 1, nil
2458
+ # - self <=> other -> -1, 0, 1, or nil
2444
2459
  # -->
2445
- # Compares File::Stat objects by comparing their respective modification times.
2460
+ # Compares `self` and `other`, by comparing their modification times; that is,
2461
+ # by comparing `self.mtime` and `other.mtime`.
2462
+ #
2463
+ # Returns:
2446
2464
  #
2447
- # `nil` is returned if `other_stat` is not a File::Stat object
2465
+ # * `-1`, if `self.mtime` is earlier.
2466
+ # * `0`, if the two values are equal.
2467
+ # * `1`, if `self.mtime` is later.
2468
+ # * `nil`, if `other` is not a File::Stat object.
2469
+ #
2470
+ # Examples:
2448
2471
  #
2449
- # f1 = File.new("f1", "w")
2450
- # sleep 1
2451
- # f2 = File.new("f2", "w")
2452
- # f1.stat <=> f2.stat #=> -1
2472
+ # stat0 = File.stat('README.md')
2473
+ # stat1 = File.stat('NEWS.md')
2474
+ # stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
2475
+ # stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
2476
+ # stat0 <=> stat1 # => -1
2477
+ # stat0 <=> stat0.dup # => 0
2478
+ # stat1 <=> stat0 # => 1
2479
+ # stat0 <=> :foo # => nil
2480
+ #
2481
+ # Class File::Stat includes module Comparable, each of whose methods uses
2482
+ # File::Stat#<=> for comparison.
2453
2483
  #
2454
2484
  def <=>: (File::Stat other) -> Integer
2455
2485
  | (untyped) -> nil
data/core/file_test.rbs CHANGED
@@ -145,7 +145,7 @@ module FileTest
145
145
  # rdoc-file=file.c
146
146
  # - File.owned?(file_name) -> true or false
147
147
  # -->
148
- # Returns `true` if the named file exists and the effective used id of the
148
+ # Returns `true` if the named file exists and the effective user id of the
149
149
  # calling process is the owner of the file.
150
150
  #
151
151
  # *file_name* can be an IO object.