rbs 3.10.0 → 4.0.0.dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +3 -3
  3. data/.github/workflows/ruby.yml +24 -35
  4. data/.github/workflows/typecheck.yml +3 -1
  5. data/.github/workflows/windows.yml +2 -2
  6. data/.gitignore +0 -4
  7. data/CHANGELOG.md +0 -88
  8. data/README.md +1 -38
  9. data/Rakefile +20 -142
  10. data/Steepfile +1 -0
  11. data/config.yml +43 -1
  12. data/core/array.rbs +46 -100
  13. data/core/complex.rbs +21 -32
  14. data/core/dir.rbs +2 -2
  15. data/core/encoding.rbs +9 -6
  16. data/core/enumerable.rbs +3 -90
  17. data/core/enumerator.rbs +1 -18
  18. data/core/errno.rbs +0 -8
  19. data/core/errors.rbs +1 -28
  20. data/core/exception.rbs +2 -2
  21. data/core/fiber.rbs +4 -5
  22. data/core/file.rbs +12 -27
  23. data/core/file_test.rbs +1 -1
  24. data/core/float.rbs +22 -209
  25. data/core/gc.rbs +281 -417
  26. data/core/hash.rbs +727 -1024
  27. data/core/integer.rbs +38 -78
  28. data/core/io/buffer.rbs +7 -18
  29. data/core/io/wait.rbs +33 -11
  30. data/core/io.rbs +12 -14
  31. data/core/kernel.rbs +51 -57
  32. data/core/marshal.rbs +1 -1
  33. data/core/match_data.rbs +1 -1
  34. data/core/math.rbs +3 -42
  35. data/core/method.rbs +6 -14
  36. data/core/module.rbs +17 -88
  37. data/core/nil_class.rbs +3 -3
  38. data/core/numeric.rbs +16 -16
  39. data/core/object.rbs +3 -3
  40. data/core/object_space.rbs +15 -21
  41. data/core/proc.rbs +8 -15
  42. data/core/process.rbs +2 -2
  43. data/core/ractor.rbs +437 -278
  44. data/core/range.rbs +8 -7
  45. data/core/rational.rbs +24 -37
  46. data/core/rbs/unnamed/argf.rbs +2 -2
  47. data/core/rbs/unnamed/env_class.rbs +1 -1
  48. data/core/rbs/unnamed/random.rbs +2 -4
  49. data/core/regexp.rbs +20 -25
  50. data/core/ruby_vm.rbs +4 -6
  51. data/core/rubygems/errors.rbs +70 -3
  52. data/core/rubygems/rubygems.rbs +79 -11
  53. data/core/rubygems/version.rbs +3 -2
  54. data/core/set.rbs +359 -488
  55. data/core/string.rbs +1228 -3153
  56. data/core/struct.rbs +1 -1
  57. data/core/symbol.rbs +4 -4
  58. data/core/thread.rbs +29 -92
  59. data/core/time.rbs +9 -35
  60. data/core/trace_point.rbs +4 -7
  61. data/core/unbound_method.rbs +6 -14
  62. data/docs/collection.md +2 -2
  63. data/docs/gem.md +1 -0
  64. data/docs/sigs.md +3 -3
  65. data/ext/rbs_extension/ast_translation.c +1077 -944
  66. data/ext/rbs_extension/ast_translation.h +0 -7
  67. data/ext/rbs_extension/class_constants.c +83 -71
  68. data/ext/rbs_extension/class_constants.h +7 -4
  69. data/ext/rbs_extension/extconf.rb +2 -24
  70. data/ext/rbs_extension/legacy_location.c +172 -173
  71. data/ext/rbs_extension/legacy_location.h +3 -8
  72. data/ext/rbs_extension/main.c +289 -239
  73. data/ext/rbs_extension/rbs_extension.h +0 -3
  74. data/ext/rbs_extension/rbs_string_bridging.h +0 -4
  75. data/include/rbs/ast.h +98 -37
  76. data/include/rbs/defines.h +12 -38
  77. data/include/rbs/lexer.h +114 -126
  78. data/include/rbs/location.h +14 -14
  79. data/include/rbs/parser.h +37 -21
  80. data/include/rbs/string.h +5 -3
  81. data/include/rbs/util/rbs_allocator.h +19 -40
  82. data/include/rbs/util/rbs_assert.h +1 -12
  83. data/include/rbs/util/rbs_constant_pool.h +3 -3
  84. data/include/rbs/util/rbs_encoding.h +1 -3
  85. data/include/rbs/util/rbs_unescape.h +1 -2
  86. data/lib/rbs/ast/ruby/annotations.rb +119 -0
  87. data/lib/rbs/ast/ruby/comment_block.rb +221 -0
  88. data/lib/rbs/ast/ruby/declarations.rb +86 -0
  89. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
  90. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  91. data/lib/rbs/ast/ruby/members.rb +213 -0
  92. data/lib/rbs/buffer.rb +104 -24
  93. data/lib/rbs/cli/validate.rb +40 -35
  94. data/lib/rbs/cli.rb +5 -6
  95. data/lib/rbs/collection/config/lockfile_generator.rb +0 -1
  96. data/lib/rbs/collection.rb +0 -1
  97. data/lib/rbs/definition.rb +6 -1
  98. data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
  99. data/lib/rbs/definition_builder/method_builder.rb +45 -30
  100. data/lib/rbs/definition_builder.rb +44 -9
  101. data/lib/rbs/environment/class_entry.rb +69 -0
  102. data/lib/rbs/environment/module_entry.rb +66 -0
  103. data/lib/rbs/environment.rb +244 -218
  104. data/lib/rbs/environment_loader.rb +3 -3
  105. data/lib/rbs/errors.rb +5 -4
  106. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  107. data/lib/rbs/inline_parser.rb +206 -0
  108. data/lib/rbs/location_aux.rb +35 -3
  109. data/lib/rbs/parser_aux.rb +11 -6
  110. data/lib/rbs/prototype/runtime.rb +2 -2
  111. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  112. data/lib/rbs/resolver/type_name_resolver.rb +38 -124
  113. data/lib/rbs/source.rb +99 -0
  114. data/lib/rbs/subtractor.rb +4 -3
  115. data/lib/rbs/test/type_check.rb +0 -14
  116. data/lib/rbs/types.rb +1 -3
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs.rb +13 -1
  119. data/lib/rdoc/discover.rb +1 -1
  120. data/lib/rdoc_plugin/parser.rb +1 -1
  121. data/rbs.gemspec +1 -0
  122. data/sig/ancestor_builder.rbs +1 -1
  123. data/sig/ast/ruby/annotations.rbs +110 -0
  124. data/sig/ast/ruby/comment_block.rbs +119 -0
  125. data/sig/ast/ruby/declarations.rbs +60 -0
  126. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  127. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  128. data/sig/ast/ruby/members.rbs +72 -0
  129. data/sig/buffer.rbs +63 -5
  130. data/sig/definition.rbs +1 -0
  131. data/sig/definition_builder.rbs +1 -1
  132. data/sig/environment/class_entry.rbs +50 -0
  133. data/sig/environment/module_entry.rbs +50 -0
  134. data/sig/environment.rbs +28 -133
  135. data/sig/errors.rbs +13 -6
  136. data/sig/inline_parser/comment_association.rbs +71 -0
  137. data/sig/inline_parser.rbs +87 -0
  138. data/sig/location.rbs +32 -7
  139. data/sig/manifest.yaml +1 -0
  140. data/sig/method_builder.rbs +7 -4
  141. data/sig/parser.rbs +16 -20
  142. data/sig/resolver/type_name_resolver.rbs +7 -38
  143. data/sig/source.rbs +48 -0
  144. data/sig/types.rbs +1 -4
  145. data/src/ast.c +290 -201
  146. data/src/lexer.c +2813 -2902
  147. data/src/lexer.re +4 -0
  148. data/src/lexstate.c +155 -169
  149. data/src/location.c +40 -40
  150. data/src/parser.c +2665 -2433
  151. data/src/string.c +48 -0
  152. data/src/util/rbs_allocator.c +77 -80
  153. data/src/util/rbs_assert.c +10 -10
  154. data/src/util/rbs_buffer.c +2 -2
  155. data/src/util/rbs_constant_pool.c +15 -13
  156. data/src/util/rbs_encoding.c +4062 -20097
  157. data/src/util/rbs_unescape.c +48 -85
  158. data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
  159. data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
  160. data/stdlib/cgi/0/core.rbs +396 -2
  161. data/stdlib/cgi/0/manifest.yaml +0 -1
  162. data/stdlib/coverage/0/coverage.rbs +1 -3
  163. data/stdlib/date/0/date.rbs +59 -67
  164. data/stdlib/date/0/date_time.rbs +1 -1
  165. data/stdlib/delegate/0/delegator.rbs +7 -10
  166. data/stdlib/erb/0/erb.rbs +347 -737
  167. data/stdlib/fileutils/0/fileutils.rbs +13 -18
  168. data/stdlib/forwardable/0/forwardable.rbs +0 -3
  169. data/stdlib/json/0/json.rbs +48 -68
  170. data/stdlib/net-http/0/net-http.rbs +0 -3
  171. data/stdlib/objspace/0/objspace.rbs +4 -9
  172. data/stdlib/open-uri/0/open-uri.rbs +0 -40
  173. data/stdlib/openssl/0/openssl.rbs +228 -331
  174. data/stdlib/optparse/0/optparse.rbs +3 -3
  175. data/{core → stdlib/pathname/0}/pathname.rbs +355 -255
  176. data/stdlib/psych/0/psych.rbs +3 -3
  177. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  178. data/stdlib/resolv/0/resolv.rbs +68 -25
  179. data/stdlib/ripper/0/ripper.rbs +2 -5
  180. data/stdlib/singleton/0/singleton.rbs +0 -3
  181. data/stdlib/socket/0/socket.rbs +1 -13
  182. data/stdlib/socket/0/tcp_socket.rbs +2 -10
  183. data/stdlib/stringio/0/stringio.rbs +85 -1176
  184. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  185. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  186. data/stdlib/time/0/time.rbs +1 -1
  187. data/stdlib/timeout/0/timeout.rbs +7 -63
  188. data/stdlib/tsort/0/cyclic.rbs +0 -3
  189. data/stdlib/uri/0/common.rbs +2 -11
  190. data/stdlib/uri/0/file.rbs +1 -1
  191. data/stdlib/uri/0/generic.rbs +16 -17
  192. data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
  193. data/stdlib/zlib/0/zstream.rbs +0 -1
  194. metadata +40 -12
  195. data/.clang-format +0 -74
  196. data/.clangd +0 -2
  197. data/.github/workflows/c-check.yml +0 -54
  198. data/core/ruby.rbs +0 -53
  199. data/docs/aliases.md +0 -79
  200. data/docs/encoding.md +0 -56
  201. data/ext/rbs_extension/compat.h +0 -10
  202. data/stdlib/cgi-escape/0/escape.rbs +0 -153
data/core/integer.rbs CHANGED
@@ -146,9 +146,9 @@ class Integer < Numeric
146
146
 
147
147
  # <!--
148
148
  # rdoc-file=numeric.c
149
- # - self % other -> real_numeric
149
+ # - self % other -> real_number
150
150
  # -->
151
- # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
151
+ # Returns `self` modulo `other` as a real number.
152
152
  #
153
153
  # For integer `n` and real number `r`, these expressions are equivalent:
154
154
  #
@@ -193,13 +193,13 @@ class Integer < Numeric
193
193
 
194
194
  # <!--
195
195
  # rdoc-file=numeric.c
196
- # - self * other -> numeric
196
+ # - self * numeric -> numeric_result
197
197
  # -->
198
- # Returns the numeric product of `self` and `other`:
198
+ # Performs multiplication:
199
199
  #
200
200
  # 4 * 2 # => 8
201
- # -4 * 2 # => -8
202
201
  # 4 * -2 # => -8
202
+ # -4 * 2 # => -8
203
203
  # 4 * 2.0 # => 8.0
204
204
  # 4 * Rational(1, 3) # => (4/3)
205
205
  # 4 * Complex(2, 0) # => (8+0i)
@@ -211,47 +211,17 @@ class Integer < Numeric
211
211
 
212
212
  # <!--
213
213
  # rdoc-file=numeric.c
214
- # - self ** exponent -> numeric
214
+ # - self ** numeric -> numeric_result
215
215
  # -->
216
- # Returns `self` raised to the power `exponent`:
217
- #
218
- # # Result for non-negative Integer exponent is Integer.
219
- # 2 ** 0 # => 1
220
- # 2 ** 1 # => 2
221
- # 2 ** 2 # => 4
222
- # 2 ** 3 # => 8
223
- # -2 ** 3 # => -8
224
- # # Result for negative Integer exponent is Rational, not Float.
225
- # 2 ** -3 # => (1/8)
226
- # -2 ** -3 # => (-1/8)
227
- #
228
- # # Result for Float exponent is Float.
229
- # 2 ** 0.0 # => 1.0
230
- # 2 ** 1.0 # => 2.0
231
- # 2 ** 2.0 # => 4.0
232
- # 2 ** 3.0 # => 8.0
233
- # -2 ** 3.0 # => -8.0
234
- # 2 ** -3.0 # => 0.125
235
- # -2 ** -3.0 # => -0.125
236
- #
237
- # # Result for non-negative Complex exponent is Complex with Integer parts.
238
- # 2 ** Complex(0, 0) # => (1+0i)
239
- # 2 ** Complex(1, 0) # => (2+0i)
240
- # 2 ** Complex(2, 0) # => (4+0i)
241
- # 2 ** Complex(3, 0) # => (8+0i)
242
- # -2 ** Complex(3, 0) # => (-8+0i)
243
- # # Result for negative Complex exponent is Complex with Rational parts.
244
- # 2 ** Complex(-3, 0) # => ((1/8)+(0/1)*i)
245
- # -2 ** Complex(-3, 0) # => ((-1/8)+(0/1)*i)
246
- #
247
- # # Result for Rational exponent is Rational.
248
- # 2 ** Rational(0, 1) # => (1/1)
249
- # 2 ** Rational(1, 1) # => (2/1)
250
- # 2 ** Rational(2, 1) # => (4/1)
251
- # 2 ** Rational(3, 1) # => (8/1)
252
- # -2 ** Rational(3, 1) # => (-8/1)
253
- # 2 ** Rational(-3, 1) # => (1/8)
254
- # -2 ** Rational(-3, 1) # => (-1/8)
216
+ # Raises `self` to the power of `numeric`:
217
+ #
218
+ # 2 ** 3 # => 8
219
+ # 2 ** -3 # => (1/8)
220
+ # -2 ** 3 # => -8
221
+ # -2 ** -3 # => (-1/8)
222
+ # 2 ** 3.3 # => 9.849155306759329
223
+ # 2 ** Rational(3, 1) # => (8/1)
224
+ # 2 ** Complex(3, 0) # => (8+0i)
255
225
  #
256
226
  def **: (Integer) -> Numeric
257
227
  | (Float) -> Numeric
@@ -260,20 +230,16 @@ class Integer < Numeric
260
230
 
261
231
  # <!--
262
232
  # rdoc-file=numeric.c
263
- # - self + other -> numeric
233
+ # - self + numeric -> numeric_result
264
234
  # -->
265
- # Returns the sum of `self` and `other`:
266
- #
267
- # 1 + 1 # => 2
268
- # 1 + -1 # => 0
269
- # 1 + 0 # => 1
270
- # 1 + -2 # => -1
271
- # 1 + Complex(1, 0) # => (2+0i)
272
- # 1 + Rational(1, 1) # => (2/1)
235
+ # Performs addition:
273
236
  #
274
- # For a computation involving Floats, the result may be inexact (see Float#+):
275
- #
276
- # 1 + 3.14 # => 4.140000000000001
237
+ # 2 + 2 # => 4
238
+ # -2 + 2 # => 0
239
+ # -2 + -2 # => -4
240
+ # 2 + 2.0 # => 4.0
241
+ # 2 + Rational(2, 1) # => (4/1)
242
+ # 2 + Complex(2, 0) # => (4+0i)
277
243
  #
278
244
  def +: (Integer) -> Integer
279
245
  | (Float) -> Float
@@ -284,9 +250,9 @@ class Integer < Numeric
284
250
 
285
251
  # <!--
286
252
  # rdoc-file=numeric.c
287
- # - self - other -> numeric
253
+ # - self - numeric -> numeric_result
288
254
  # -->
289
- # Returns the difference of `self` and `other`:
255
+ # Performs subtraction:
290
256
  #
291
257
  # 4 - 2 # => 2
292
258
  # -4 - 2 # => -6
@@ -302,34 +268,28 @@ class Integer < Numeric
302
268
 
303
269
  # <!--
304
270
  # rdoc-file=numeric.rb
305
- # - -self -> integer
271
+ # - -int -> integer
306
272
  # -->
307
- # Returns `self`, negated:
308
- #
309
- # -1 # => -1
310
- # -(-1) # => 1
311
- # -0 # => 0
273
+ # Returns `self`, negated.
312
274
  #
313
275
  def -@: () -> Integer
314
276
 
315
277
  # <!--
316
278
  # rdoc-file=numeric.c
317
- # - self / other -> numeric
279
+ # - self / numeric -> numeric_result
318
280
  # -->
319
- # Returns the quotient of `self` and `other`.
320
- #
321
- # For integer `other`, truncates the result to an integer:
281
+ # Performs division; for integer `numeric`, truncates the result to an integer:
322
282
  #
323
- # 4 / 3 # => 1
324
- # 4 / -3 # => -2
325
- # -4 / 3 # => -2
326
- # -4 / -3 # => 1
283
+ # 4 / 3 # => 1
284
+ # 4 / -3 # => -2
285
+ # -4 / 3 # => -2
286
+ # -4 / -3 # => 1
327
287
  #
328
- # For non-integer `other`, returns a non-integer result:
288
+ # For other +numeric+, returns non-integer result:
329
289
  #
330
- # 4 / 3.0 # => 1.3333333333333333
331
- # 4 / Rational(3, 1) # => (4/3)
332
- # 4 / Complex(3, 0) # => ((4/3)+0i)
290
+ # 4 / 3.0 # => 1.3333333333333333
291
+ # 4 / Rational(3, 1) # => (4/3)
292
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
333
293
  #
334
294
  def /: (Integer) -> Integer
335
295
  | (Float) -> Float
@@ -995,7 +955,7 @@ class Integer < Numeric
995
955
  def magnitude: () -> Integer
996
956
 
997
957
  # <!-- rdoc-file=numeric.c -->
998
- # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
958
+ # Returns `self` modulo `other` as a real number.
999
959
  #
1000
960
  # For integer `n` and real number `r`, these expressions are equivalent:
1001
961
  #
data/core/io/buffer.rbs CHANGED
@@ -131,25 +131,18 @@ class IO
131
131
  # - IO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer
132
132
  # -->
133
133
  # Create an IO::Buffer for reading from `file` by memory-mapping the file.
134
- # `file` should be a `File` instance, opened for reading or reading and writing.
134
+ # `file_io` should be a `File` instance, opened for reading.
135
135
  #
136
- # Optional `size` and `offset` of mapping can be specified. Trying to map an
137
- # empty file or specify `size` of 0 will raise an error. Valid values for
138
- # `offset` are system-dependent.
136
+ # Optional `size` and `offset` of mapping can be specified.
139
137
  #
140
- # By default, the buffer is writable and expects the file to be writable. It is
141
- # also shared, so several processes can use the same mapping.
142
- #
143
- # You can pass IO::Buffer::READONLY in `flags` argument to make a read-only
144
- # buffer; this allows to work with files opened only for reading. Specifying
145
- # IO::Buffer::PRIVATE in `flags` creates a private mapping, which will not
146
- # impact other processes or the underlying file. It also allows updating a
147
- # buffer created from a read-only file.
138
+ # By default, the buffer would be immutable (read only); to create a writable
139
+ # mapping, you need to open a file in read-write mode, and explicitly pass
140
+ # `flags` argument without IO::Buffer::IMMUTABLE.
148
141
  #
149
142
  # File.write('test.txt', 'test')
150
143
  #
151
144
  # buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
152
- # # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
145
+ # # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
153
146
  #
154
147
  # buffer.readonly? # => true
155
148
  #
@@ -157,7 +150,7 @@ class IO
157
150
  # # => "test"
158
151
  #
159
152
  # buffer.set_string('b', 0)
160
- # # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
153
+ # # `set_string': Buffer is not writable! (IO::Buffer::AccessError)
161
154
  #
162
155
  # # create read/write mapping: length 4 bytes, offset 0, flags 0
163
156
  # buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
@@ -389,10 +382,6 @@ class IO
389
382
  # * `:U64`: unsigned integer, 8 bytes, big-endian
390
383
  # * `:s64`: signed integer, 8 bytes, little-endian
391
384
  # * `:S64`: signed integer, 8 bytes, big-endian
392
- # * `:u128`: unsigned integer, 16 bytes, little-endian
393
- # * `:U128`: unsigned integer, 16 bytes, big-endian
394
- # * `:s128`: signed integer, 16 bytes, little-endian
395
- # * `:S128`: signed integer, 16 bytes, big-endian
396
385
  # * `:f32`: float, 4 bytes, little-endian
397
386
  # * `:F32`: float, 4 bytes, big-endian
398
387
  # * `:f64`: double, 8 bytes, little-endian
data/core/io/wait.rbs CHANGED
@@ -1,9 +1,30 @@
1
1
  %a{annotate:rdoc:skip}
2
2
  class IO
3
3
  # <!--
4
- # rdoc-file=io.c
4
+ # rdoc-file=ext/io/wait/wait.c
5
+ # - io.nread -> int
6
+ # -->
7
+ # Returns number of bytes that can be read without blocking. Returns zero if no
8
+ # information available.
9
+ #
10
+ # You must require 'io/wait' to use this method.
11
+ #
12
+ def nread: () -> Integer
13
+
14
+ # <!--
15
+ # rdoc-file=ext/io/wait/wait.c
16
+ # - io.ready? -> truthy or falsy
17
+ # -->
18
+ # Returns a truthy value if input available without blocking, or a falsy value.
19
+ #
20
+ # You must require 'io/wait' to use this method.
21
+ #
22
+ def ready?: () -> boolish
23
+
24
+ # <!--
25
+ # rdoc-file=ext/io/wait/wait.c
5
26
  # - io.wait(events, timeout) -> event mask, false or nil
6
- # - io.wait(*event_symbols[, timeout]) -> self, true, or false
27
+ # - io.wait(timeout = nil, mode = :read) -> self, true, or false
7
28
  # -->
8
29
  # Waits until the IO becomes ready for the specified events and returns the
9
30
  # subset of events that become ready, or a falsy value when times out.
@@ -11,14 +32,11 @@ class IO
11
32
  # The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
12
33
  # `IO::PRIORITY`.
13
34
  #
14
- # Returns an event mask (truthy value) immediately when buffered data is
15
- # available.
35
+ # Returns a truthy value immediately when buffered data is available.
16
36
  #
17
- # The second form: if one or more event symbols (`:read`, `:write`, or
18
- # `:read_write`) are passed, the event mask is the bit OR of the bitmask
19
- # corresponding to those symbols. In this form, `timeout` is optional, the
20
- # order of the arguments is arbitrary, and returns `io` if any of the events is
21
- # ready.
37
+ # Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`.
38
+ #
39
+ # You must require 'io/wait' to use this method.
22
40
  #
23
41
  def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
24
42
  | (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
@@ -26,7 +44,7 @@ class IO
26
44
  type wait_mode = :read | :r | :readable | :write | :w | :writable | :read_write | :rw | :readable_writable
27
45
 
28
46
  # <!--
29
- # rdoc-file=io.c
47
+ # rdoc-file=ext/io/wait/wait.c
30
48
  # - io.wait_readable -> truthy or falsy
31
49
  # - io.wait_readable(timeout) -> truthy or falsy
32
50
  # -->
@@ -34,15 +52,19 @@ class IO
34
52
  # times out. Returns a truthy value immediately when buffered data is
35
53
  # available.
36
54
  #
55
+ # You must require 'io/wait' to use this method.
56
+ #
37
57
  def wait_readable: (?Time::_Timeout? timeout) -> boolish
38
58
 
39
59
  # <!--
40
- # rdoc-file=io.c
60
+ # rdoc-file=ext/io/wait/wait.c
41
61
  # - io.wait_writable -> truthy or falsy
42
62
  # - io.wait_writable(timeout) -> truthy or falsy
43
63
  # -->
44
64
  # Waits until IO is writable and returns a truthy value or a falsy value when
45
65
  # times out.
46
66
  #
67
+ # You must require 'io/wait' to use this method.
68
+ #
47
69
  def wait_writable: (?Time::_Timeout? timeout) -> boolish
48
70
  end
data/core/io.rbs CHANGED
@@ -1373,7 +1373,7 @@ class IO < Object
1373
1373
  # Formats and writes `objects` to the stream.
1374
1374
  #
1375
1375
  # For details on `format_string`, see [Format
1376
- # Specifications](rdoc-ref:language/format_specifications.rdoc).
1376
+ # Specifications](rdoc-ref:format_specifications.rdoc).
1377
1377
  #
1378
1378
  def printf: (String format_string, *untyped objects) -> nil
1379
1379
 
@@ -2276,7 +2276,7 @@ class IO < Object
2276
2276
  #
2277
2277
  # When called from class IO (but not subclasses of IO), this method has
2278
2278
  # potential security vulnerabilities if called with untrusted input; see
2279
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2279
+ # [Command Injection](rdoc-ref:command_injection.rdoc).
2280
2280
  #
2281
2281
  def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
2282
2282
 
@@ -2289,7 +2289,7 @@ class IO < Object
2289
2289
  #
2290
2290
  # When called from class IO (but not subclasses of IO), this method has
2291
2291
  # potential security vulnerabilities if called with untrusted input; see
2292
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2292
+ # [Command Injection](rdoc-ref:command_injection.rdoc).
2293
2293
  #
2294
2294
  def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
2295
2295
 
@@ -2354,16 +2354,15 @@ class IO < Object
2354
2354
  # connected to a new stream `io`.
2355
2355
  #
2356
2356
  # This method has potential security vulnerabilities if called with untrusted
2357
- # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
2357
+ # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
2358
2358
  #
2359
2359
  # If no block is given, returns the new stream, which depending on given `mode`
2360
2360
  # may be open for reading, writing, or both. The stream should be explicitly
2361
2361
  # closed (eventually) to avoid resource leaks.
2362
2362
  #
2363
2363
  # If a block is given, the stream is passed to the block (again, open for
2364
- # reading, writing, or both); when the block exits, the stream is closed, the
2365
- # block's value is returned, and the global variable `$?` is set to the child's
2366
- # exit status.
2364
+ # reading, writing, or both); when the block exits, the stream is closed, and
2365
+ # the block's value is assigned to global variable `$?` and returned.
2367
2366
  #
2368
2367
  # Optional argument `mode` may be any valid IO mode. See [Access
2369
2368
  # Modes](rdoc-ref:File@Access+Modes).
@@ -2392,7 +2391,7 @@ class IO < Object
2392
2391
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2393
2392
  # * Options for Kernel#spawn.
2394
2393
  #
2395
- # **Forked Process**
2394
+ # **Forked \Process**
2396
2395
  #
2397
2396
  # When argument `cmd` is the 1-character string `'-'`, causes the process to
2398
2397
  # fork:
@@ -2529,7 +2528,7 @@ class IO < Object
2529
2528
  #
2530
2529
  # When called from class IO (but not subclasses of IO), this method has
2531
2530
  # potential security vulnerabilities if called with untrusted input; see
2532
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2531
+ # [Command Injection](rdoc-ref:command_injection.rdoc).
2533
2532
  #
2534
2533
  # The first argument must be a string that is the path to a file.
2535
2534
  #
@@ -2686,7 +2685,7 @@ class IO < Object
2686
2685
  #
2687
2686
  # When called from class IO (but not subclasses of IO), this method has
2688
2687
  # potential security vulnerabilities if called with untrusted input; see
2689
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2688
+ # [Command Injection](rdoc-ref:command_injection.rdoc).
2690
2689
  #
2691
2690
  # The first argument must be a string that is the path to a file.
2692
2691
  #
@@ -2729,7 +2728,7 @@ class IO < Object
2729
2728
  #
2730
2729
  # When called from class IO (but not subclasses of IO), this method has
2731
2730
  # potential security vulnerabilities if called with untrusted input; see
2732
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2731
+ # [Command Injection](rdoc-ref:command_injection.rdoc).
2733
2732
  #
2734
2733
  # The first argument must be a string that is the path to a file.
2735
2734
  #
@@ -2786,8 +2785,7 @@ class IO < Object
2786
2785
  # IO objects.
2787
2786
  #
2788
2787
  # Argument `timeout` is a numeric value (such as integer or float) timeout
2789
- # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
2790
- # and `Float::INFINITY` means no timeout.
2788
+ # interval in seconds.
2791
2789
  #
2792
2790
  # The method monitors the IO objects given in all three arrays, waiting for some
2793
2791
  # to be ready; returns a 3-element array whose elements are:
@@ -2954,7 +2952,7 @@ class IO < Object
2954
2952
  #
2955
2953
  # When called from class IO (but not subclasses of IO), this method has
2956
2954
  # potential security vulnerabilities if called with untrusted input; see
2957
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2955
+ # [Command Injection](rdoc-ref:command_injection.rdoc).
2958
2956
  #
2959
2957
  # The first argument must be a string that is the path to a file.
2960
2958
  #
data/core/kernel.rbs CHANGED
@@ -80,7 +80,7 @@
80
80
  # * #print: Prints the given objects to standard output without a newline.
81
81
  # * #printf: Prints the string resulting from applying the given format string
82
82
  # to any additional arguments.
83
- # * #putc: Equivalent to `$stdout.putc(object)` for the given object.
83
+ # * #putc: Equivalent to <tt.$stdout.putc(object)</tt> for the given object.
84
84
  # * #puts: Equivalent to `$stdout.puts(*objects)` for the given objects.
85
85
  # * #readline: Similar to #gets, but raises an exception at the end of file.
86
86
  # * #readlines: Returns an array of the remaining lines from the current
@@ -718,14 +718,14 @@ module Kernel : BasicObject
718
718
  # variable `$?` to the process status.
719
719
  #
720
720
  # This method has potential security vulnerabilities if called with untrusted
721
- # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
721
+ # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
722
722
  #
723
723
  # Examples:
724
724
  #
725
725
  # $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n"
726
726
  # $ `echo oops && exit 99` # => "oops\n"
727
727
  # $ $? # => #<Process::Status: pid 17088 exit 99>
728
- # $ $?.exitstatus # => 99
728
+ # $ $?.status # => 99>
729
729
  #
730
730
  # The built-in syntax `%x{...}` uses this method.
731
731
  #
@@ -777,8 +777,6 @@ module Kernel : BasicObject
777
777
  # If *const* is defined as autoload, the file name to be loaded is replaced with
778
778
  # *filename*. If *const* is defined but not as autoload, does nothing.
779
779
  #
780
- # Files that are currently being loaded must not be registered for autoload.
781
- #
782
780
  def self?.autoload: (interned _module, String filename) -> NilClass
783
781
 
784
782
  # <!--
@@ -1118,7 +1116,7 @@ module Kernel : BasicObject
1118
1116
  # Returns the string resulting from formatting `objects` into `format_string`.
1119
1117
  #
1120
1118
  # For details on `format_string`, see [Format
1121
- # Specifications](rdoc-ref:language/format_specifications.rdoc).
1119
+ # Specifications](rdoc-ref:format_specifications.rdoc).
1122
1120
  #
1123
1121
  def self?.format: (String format, *untyped args) -> String
1124
1122
 
@@ -1129,7 +1127,7 @@ module Kernel : BasicObject
1129
1127
  # Returns the string resulting from formatting `objects` into `format_string`.
1130
1128
  #
1131
1129
  # For details on `format_string`, see [Format
1132
- # Specifications](rdoc-ref:language/format_specifications.rdoc).
1130
+ # Specifications](rdoc-ref:format_specifications.rdoc).
1133
1131
  #
1134
1132
  alias sprintf format
1135
1133
 
@@ -1220,7 +1218,6 @@ module Kernel : BasicObject
1220
1218
  # loop do
1221
1219
  # print "Input: "
1222
1220
  # line = gets
1223
- # # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
1224
1221
  # break if !line or line =~ /^q/i
1225
1222
  # # ...
1226
1223
  # end
@@ -1249,7 +1246,7 @@ module Kernel : BasicObject
1249
1246
  # Creates an IO object connected to the given file.
1250
1247
  #
1251
1248
  # This method has potential security vulnerabilities if called with untrusted
1252
- # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1249
+ # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
1253
1250
  #
1254
1251
  # With no block given, file stream is returned:
1255
1252
  #
@@ -1327,7 +1324,7 @@ module Kernel : BasicObject
1327
1324
  # io.write(sprintf(format_string, *objects))
1328
1325
  #
1329
1326
  # For details on `format_string`, see [Format
1330
- # Specifications](rdoc-ref:language/format_specifications.rdoc).
1327
+ # Specifications](rdoc-ref:format_specifications.rdoc).
1331
1328
  #
1332
1329
  # With the single argument `format_string`, formats `objects` into the string,
1333
1330
  # then writes the formatted string to $stdout:
@@ -1466,9 +1463,7 @@ module Kernel : BasicObject
1466
1463
  # Kernel.srand may be used to ensure that sequences of random numbers are
1467
1464
  # reproducible between different runs of a program.
1468
1465
  #
1469
- # Related: Random.rand.
1470
- # rand(100.0) # => 64 (Integer because max.to_i is 100)
1471
- # Random.rand(100.0) # => 30.315320967824523
1466
+ # See also Random.rand.
1472
1467
  #
1473
1468
  def self?.rand: (?0) -> Float
1474
1469
  | (int arg0) -> Integer
@@ -1590,8 +1585,7 @@ module Kernel : BasicObject
1590
1585
  # IO objects.
1591
1586
  #
1592
1587
  # Argument `timeout` is a numeric value (such as integer or float) timeout
1593
- # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
1594
- # and `Float::INFINITY` means no timeout.
1588
+ # interval in seconds.
1595
1589
  #
1596
1590
  # The method monitors the IO objects given in all three arrays, waiting for some
1597
1591
  # to be ready; returns a 3-element array whose elements are:
@@ -1779,58 +1773,58 @@ module Kernel : BasicObject
1779
1773
  # * Each of these tests operates only on the entity at `path0`,
1780
1774
  # and returns `true` or `false`;
1781
1775
  # for a non-existent entity, returns `false` (does not raise exception):
1782
- # Character|Test
1783
- # ---------|-------------------------------------------------------------------
1784
- # `'b'` |Whether the entity is a block device.
1785
- # `'c'` |Whether the entity is a character device.
1786
- # `'d'` |Whether the entity is a directory.
1787
- # `'e'` |Whether the entity is an existing entity.
1788
- # `'f'` |Whether the entity is an existing regular file.
1789
- # `'g'` |Whether the entity's setgid bit is set.
1790
- # `'G'` |Whether the entity's group ownership is equal to the caller's.
1791
- # `'k'` |Whether the entity's sticky bit is set.
1792
- # `'l'` |Whether the entity is a symbolic link.
1793
- # `'o'` |Whether the entity is owned by the caller's effective uid.
1794
- # `'O'` |Like `'o'`, but uses the real uid (not the effective uid).
1795
- # `'p'` |Whether the entity is a FIFO device (named pipe).
1796
- # `'r'` |Whether the entity is readable by the caller's effective uid/gid.
1797
- # `'R'` |Like `'r'`, but uses the real uid/gid (not the effective uid/gid).
1798
- # `'S'` |Whether the entity is a socket.
1799
- # `'u'` |Whether the entity's setuid bit is set.
1800
- # `'w'` |Whether the entity is writable by the caller's effective uid/gid.
1801
- # `'W'` |Like `'w'`, but uses the real uid/gid (not the effective uid/gid).
1802
- # `'x'` |Whether the entity is executable by the caller's effective uid/gid.
1803
- # `'X'` |Like `'x'`, but uses the real uid/gid (not the effective uid/git).
1804
- # `'z'` |Whether the entity exists and is of length zero.
1776
+ # Character |Test
1777
+ # ------------|-------------------------------------------------------------------------
1778
+ # <tt>'b'</tt>|Whether the entity is a block device.
1779
+ # <tt>'c'</tt>|Whether the entity is a character device.
1780
+ # <tt>'d'</tt>|Whether the entity is a directory.
1781
+ # <tt>'e'</tt>|Whether the entity is an existing entity.
1782
+ # <tt>'f'</tt>|Whether the entity is an existing regular file.
1783
+ # <tt>'g'</tt>|Whether the entity's setgid bit is set.
1784
+ # <tt>'G'</tt>|Whether the entity's group ownership is equal to the caller's.
1785
+ # <tt>'k'</tt>|Whether the entity's sticky bit is set.
1786
+ # <tt>'l'</tt>|Whether the entity is a symbolic link.
1787
+ # <tt>'o'</tt>|Whether the entity is owned by the caller's effective uid.
1788
+ # <tt>'O'</tt>|Like <tt>'o'</tt>, but uses the real uid (not the effective uid).
1789
+ # <tt>'p'</tt>|Whether the entity is a FIFO device (named pipe).
1790
+ # <tt>'r'</tt>|Whether the entity is readable by the caller's effective uid/gid.
1791
+ # <tt>'R'</tt>|Like <tt>'r'</tt>, but uses the real uid/gid (not the effective uid/gid).
1792
+ # <tt>'S'</tt>|Whether the entity is a socket.
1793
+ # <tt>'u'</tt>|Whether the entity's setuid bit is set.
1794
+ # <tt>'w'</tt>|Whether the entity is writable by the caller's effective uid/gid.
1795
+ # <tt>'W'</tt>|Like <tt>'w'</tt>, but uses the real uid/gid (not the effective uid/gid).
1796
+ # <tt>'x'</tt>|Whether the entity is executable by the caller's effective uid/gid.
1797
+ # <tt>'X'</tt>|Like <tt>'x'</tt>, but uses the real uid/gid (not the effective uid/git).
1798
+ # <tt>'z'</tt>|Whether the entity exists and is of length zero.
1805
1799
  # * This test operates only on the entity at `path0`,
1806
1800
  # and returns an integer size or `nil`:
1807
- # Character|Test
1808
- # ---------|--------------------------------------------------------------------------------------------
1809
- # `'s'` |Returns positive integer size if the entity exists and has non-zero length, `nil` otherwise.
1801
+ # Character |Test
1802
+ # ------------|--------------------------------------------------------------------------------------------
1803
+ # <tt>'s'</tt>|Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise.
1810
1804
  # * Each of these tests operates only on the entity at `path0`,
1811
1805
  # and returns a Time object;
1812
1806
  # raises an exception if the entity does not exist:
1813
- # Character|Test
1814
- # ---------|--------------------------------------
1815
- # `'A'` |Last access time for the entity.
1816
- # `'C'` |Last change time for the entity.
1817
- # `'M'` |Last modification time for the entity.
1807
+ # Character |Test
1808
+ # ------------|--------------------------------------
1809
+ # <tt>'A'</tt>|Last access time for the entity.
1810
+ # <tt>'C'</tt>|Last change time for the entity.
1811
+ # <tt>'M'</tt>|Last modification time for the entity.
1818
1812
  # * Each of these tests operates on the modification time (`mtime`)
1819
1813
  # of each of the entities at `path0` and `path1`,
1820
1814
  # and returns a `true` or `false`;
1821
1815
  # returns `false` if either entity does not exist:
1822
- # Character|Test
1823
- # ---------|---------------------------------------------------------------
1824
- # `'<'` |Whether the `mtime` at `path0` is less than that at `path1`.
1825
- # `'='` |Whether the `mtime` at `path0` is equal to that at `path1`.
1826
- # `'>'` |Whether the `mtime` at `path0` is greater than that at `path1`.
1816
+ # Character |Test
1817
+ # ------------|---------------------------------------------------------------
1818
+ # <tt>'<'</tt>|Whether the `mtime` at `path0` is less than that at `path1`.
1819
+ # <tt>'='</tt>|Whether the `mtime` at `path0` is equal to that at `path1`.
1820
+ # <tt>'>'</tt>|Whether the `mtime` at `path0` is greater than that at `path1`.
1827
1821
  # * This test operates on the content of each of the entities at `path0` and
1828
1822
  # `path1`,
1829
1823
  # and returns a `true` or `false`;
1830
1824
  # returns `false` if either entity does not exist:
1831
- # Character|Test
1832
- # ---------|---------------------------------------------
1833
- # `'-'` |Whether the entities exist and are identical.
1825
+ # Character |Test
1826
+ # ------------|---------------------------------------------
1827
+ # <tt>'-'</tt>|Whether the entities exist and are identical.
1834
1828
  #
1835
1829
  def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
1836
1830
 
@@ -1907,7 +1901,7 @@ module Kernel : BasicObject
1907
1901
  # * Invoking the executable at `exe_path`.
1908
1902
  #
1909
1903
  # This method has potential security vulnerabilities if called with untrusted
1910
- # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1904
+ # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
1911
1905
  #
1912
1906
  # The new process is created using the [exec system
1913
1907
  # call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
@@ -1999,7 +1993,7 @@ module Kernel : BasicObject
1999
1993
  # * Invoking the executable at `exe_path`.
2000
1994
  #
2001
1995
  # This method has potential security vulnerabilities if called with untrusted
2002
- # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1996
+ # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
2003
1997
  #
2004
1998
  # Returns the process ID (pid) of the new process, without waiting for it to
2005
1999
  # complete.
@@ -2102,7 +2096,7 @@ module Kernel : BasicObject
2102
2096
  # * Invoking the executable at `exe_path`.
2103
2097
  #
2104
2098
  # This method has potential security vulnerabilities if called with untrusted
2105
- # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
2099
+ # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
2106
2100
  #
2107
2101
  # Returns:
2108
2102
  #
data/core/marshal.rbs CHANGED
@@ -147,7 +147,7 @@ module Marshal
147
147
  # * anonymous Class/Module.
148
148
  # * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket
149
149
  # and so on)
150
- # * an instance of MatchData, Method, UnboundMethod, Proc, Thread,
150
+ # * an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread,
151
151
  # ThreadGroup, Continuation
152
152
  # * objects which define singleton methods
153
153
  #
data/core/match_data.rbs CHANGED
@@ -41,7 +41,7 @@
41
41
  # * `$'` is Regexp.last_match`.post_match`;
42
42
  # * `$+` is Regexp.last_match`[ -1 ]` (the last capture).
43
43
  #
44
- # See also Regexp@Global+Variables.
44
+ # See also "Special global variables" section in Regexp documentation.
45
45
  #
46
46
  class MatchData
47
47
  type capture = String | Symbol | int