rbs 3.9.5 → 3.10.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 (189) 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 +3 -3
  6. data/.github/workflows/ruby.yml +34 -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 +49 -0
  11. data/README.md +38 -1
  12. data/Rakefile +152 -23
  13. data/config.yml +190 -62
  14. data/core/array.rbs +100 -46
  15. data/core/complex.rbs +32 -21
  16. data/core/dir.rbs +2 -2
  17. data/core/encoding.rbs +6 -9
  18. data/core/enumerable.rbs +90 -3
  19. data/core/enumerator.rbs +18 -1
  20. data/core/errno.rbs +8 -0
  21. data/core/errors.rbs +28 -1
  22. data/core/exception.rbs +2 -2
  23. data/core/fiber.rbs +5 -4
  24. data/core/file.rbs +27 -12
  25. data/core/file_test.rbs +1 -1
  26. data/core/float.rbs +209 -22
  27. data/core/gc.rbs +417 -281
  28. data/core/hash.rbs +1024 -727
  29. data/core/integer.rbs +78 -38
  30. data/core/io/buffer.rbs +18 -7
  31. data/core/io/wait.rbs +11 -33
  32. data/core/io.rbs +14 -12
  33. data/core/kernel.rbs +57 -51
  34. data/core/marshal.rbs +1 -1
  35. data/core/match_data.rbs +1 -1
  36. data/core/math.rbs +42 -3
  37. data/core/method.rbs +14 -6
  38. data/core/module.rbs +88 -17
  39. data/core/nil_class.rbs +3 -3
  40. data/core/numeric.rbs +16 -16
  41. data/core/object.rbs +3 -3
  42. data/core/object_space.rbs +21 -15
  43. data/{stdlib/pathname/0 → core}/pathname.rbs +255 -355
  44. data/core/proc.rbs +15 -8
  45. data/core/process.rbs +2 -2
  46. data/core/ractor.rbs +278 -437
  47. data/core/range.rbs +7 -8
  48. data/core/rational.rbs +37 -24
  49. data/core/rbs/unnamed/argf.rbs +2 -2
  50. data/core/rbs/unnamed/env_class.rbs +1 -1
  51. data/core/rbs/unnamed/random.rbs +4 -2
  52. data/core/regexp.rbs +25 -20
  53. data/core/ruby.rbs +53 -0
  54. data/core/ruby_vm.rbs +6 -4
  55. data/core/rubygems/errors.rbs +3 -70
  56. data/core/rubygems/rubygems.rbs +11 -79
  57. data/core/rubygems/version.rbs +2 -3
  58. data/core/set.rbs +488 -359
  59. data/core/string.rbs +3145 -1231
  60. data/core/struct.rbs +1 -1
  61. data/core/symbol.rbs +4 -4
  62. data/core/thread.rbs +92 -29
  63. data/core/time.rbs +35 -9
  64. data/core/trace_point.rbs +7 -4
  65. data/core/unbound_method.rbs +14 -6
  66. data/docs/aliases.md +79 -0
  67. data/docs/collection.md +2 -2
  68. data/docs/encoding.md +56 -0
  69. data/docs/gem.md +0 -1
  70. data/docs/sigs.md +3 -3
  71. data/ext/rbs_extension/ast_translation.c +1016 -0
  72. data/ext/rbs_extension/ast_translation.h +37 -0
  73. data/ext/rbs_extension/class_constants.c +155 -0
  74. data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
  75. data/ext/rbs_extension/compat.h +10 -0
  76. data/ext/rbs_extension/extconf.rb +25 -1
  77. data/ext/rbs_extension/legacy_location.c +317 -0
  78. data/ext/rbs_extension/legacy_location.h +45 -0
  79. data/ext/rbs_extension/main.c +357 -14
  80. data/ext/rbs_extension/rbs_extension.h +6 -21
  81. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  82. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  83. data/include/rbs/ast.h +687 -0
  84. data/include/rbs/defines.h +86 -0
  85. data/include/rbs/lexer.h +199 -0
  86. data/include/rbs/location.h +59 -0
  87. data/include/rbs/parser.h +135 -0
  88. data/include/rbs/string.h +47 -0
  89. data/include/rbs/util/rbs_allocator.h +59 -0
  90. data/include/rbs/util/rbs_assert.h +20 -0
  91. data/include/rbs/util/rbs_buffer.h +83 -0
  92. data/include/rbs/util/rbs_constant_pool.h +6 -67
  93. data/include/rbs/util/rbs_encoding.h +282 -0
  94. data/include/rbs/util/rbs_unescape.h +24 -0
  95. data/include/rbs.h +1 -2
  96. data/lib/rbs/annotate/formatter.rb +3 -13
  97. data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
  98. data/lib/rbs/annotate/rdoc_source.rb +1 -1
  99. data/lib/rbs/cli/validate.rb +2 -2
  100. data/lib/rbs/cli.rb +1 -1
  101. data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
  102. data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
  103. data/lib/rbs/environment.rb +64 -59
  104. data/lib/rbs/environment_loader.rb +1 -1
  105. data/lib/rbs/errors.rb +1 -1
  106. data/lib/rbs/parser_aux.rb +5 -0
  107. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  108. data/lib/rbs/resolver/type_name_resolver.rb +124 -38
  109. data/lib/rbs/test/type_check.rb +14 -0
  110. data/lib/rbs/types.rb +3 -1
  111. data/lib/rbs/version.rb +1 -1
  112. data/lib/rbs.rb +1 -1
  113. data/lib/rdoc/discover.rb +1 -1
  114. data/lib/rdoc_plugin/parser.rb +3 -3
  115. data/sig/annotate/formatter.rbs +2 -2
  116. data/sig/annotate/rdoc_annotater.rbs +1 -1
  117. data/sig/environment.rbs +57 -6
  118. data/sig/manifest.yaml +0 -1
  119. data/sig/parser.rbs +20 -0
  120. data/sig/resolver/type_name_resolver.rbs +38 -7
  121. data/sig/types.rbs +4 -1
  122. data/src/ast.c +1256 -0
  123. data/src/lexer.c +2956 -0
  124. data/src/lexer.re +147 -0
  125. data/src/lexstate.c +205 -0
  126. data/src/location.c +71 -0
  127. data/src/parser.c +3507 -0
  128. data/src/string.c +41 -0
  129. data/src/util/rbs_allocator.c +152 -0
  130. data/src/util/rbs_assert.c +19 -0
  131. data/src/util/rbs_buffer.c +54 -0
  132. data/src/util/rbs_constant_pool.c +18 -88
  133. data/src/util/rbs_encoding.c +21308 -0
  134. data/src/util/rbs_unescape.c +167 -0
  135. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  136. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  137. data/stdlib/cgi/0/core.rbs +2 -396
  138. data/stdlib/cgi/0/manifest.yaml +1 -0
  139. data/stdlib/cgi-escape/0/escape.rbs +153 -0
  140. data/stdlib/coverage/0/coverage.rbs +3 -1
  141. data/stdlib/date/0/date.rbs +67 -59
  142. data/stdlib/date/0/date_time.rbs +1 -1
  143. data/stdlib/delegate/0/delegator.rbs +10 -7
  144. data/stdlib/erb/0/erb.rbs +737 -347
  145. data/stdlib/fileutils/0/fileutils.rbs +18 -13
  146. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  147. data/stdlib/json/0/json.rbs +68 -48
  148. data/stdlib/net-http/0/net-http.rbs +3 -0
  149. data/stdlib/objspace/0/objspace.rbs +9 -4
  150. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  151. data/stdlib/openssl/0/openssl.rbs +331 -228
  152. data/stdlib/optparse/0/optparse.rbs +3 -3
  153. data/stdlib/psych/0/psych.rbs +3 -3
  154. data/stdlib/rdoc/0/code_object.rbs +2 -2
  155. data/stdlib/rdoc/0/comment.rbs +2 -0
  156. data/stdlib/rdoc/0/options.rbs +76 -0
  157. data/stdlib/rdoc/0/rdoc.rbs +7 -5
  158. data/stdlib/rdoc/0/store.rbs +1 -1
  159. data/stdlib/resolv/0/resolv.rbs +25 -68
  160. data/stdlib/ripper/0/ripper.rbs +5 -2
  161. data/stdlib/singleton/0/singleton.rbs +3 -0
  162. data/stdlib/socket/0/socket.rbs +13 -1
  163. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  164. data/stdlib/stringio/0/stringio.rbs +1176 -85
  165. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  166. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  167. data/stdlib/time/0/time.rbs +1 -1
  168. data/stdlib/timeout/0/timeout.rbs +63 -7
  169. data/stdlib/tsort/0/cyclic.rbs +3 -0
  170. data/stdlib/uri/0/common.rbs +11 -2
  171. data/stdlib/uri/0/file.rbs +1 -1
  172. data/stdlib/uri/0/generic.rbs +17 -16
  173. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  174. data/stdlib/zlib/0/zstream.rbs +1 -0
  175. metadata +43 -18
  176. data/ext/rbs_extension/lexer.c +0 -2728
  177. data/ext/rbs_extension/lexer.h +0 -179
  178. data/ext/rbs_extension/lexer.re +0 -147
  179. data/ext/rbs_extension/lexstate.c +0 -175
  180. data/ext/rbs_extension/location.c +0 -325
  181. data/ext/rbs_extension/location.h +0 -85
  182. data/ext/rbs_extension/parser.c +0 -2982
  183. data/ext/rbs_extension/parser.h +0 -18
  184. data/ext/rbs_extension/parserstate.c +0 -411
  185. data/ext/rbs_extension/parserstate.h +0 -163
  186. data/ext/rbs_extension/unescape.c +0 -32
  187. data/include/rbs/ruby_objs.h +0 -72
  188. data/src/constants.c +0 -153
  189. data/src/ruby_objs.c +0 -799
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_number
149
+ # - self % other -> real_numeric
150
150
  # -->
151
- # Returns `self` modulo `other` as a real number.
151
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
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 * numeric -> numeric_result
196
+ # - self * other -> numeric
197
197
  # -->
198
- # Performs multiplication:
198
+ # Returns the numeric product of `self` and `other`:
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,17 +211,47 @@ class Integer < Numeric
211
211
 
212
212
  # <!--
213
213
  # rdoc-file=numeric.c
214
- # - self ** numeric -> numeric_result
214
+ # - self ** exponent -> numeric
215
215
  # -->
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)
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)
225
255
  #
226
256
  def **: (Integer) -> Numeric
227
257
  | (Float) -> Numeric
@@ -230,16 +260,20 @@ class Integer < Numeric
230
260
 
231
261
  # <!--
232
262
  # rdoc-file=numeric.c
233
- # - self + numeric -> numeric_result
263
+ # - self + other -> numeric
234
264
  # -->
235
- # Performs addition:
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)
236
273
  #
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)
274
+ # For a computation involving Floats, the result may be inexact (see Float#+):
275
+ #
276
+ # 1 + 3.14 # => 4.140000000000001
243
277
  #
244
278
  def +: (Integer) -> Integer
245
279
  | (Float) -> Float
@@ -250,9 +284,9 @@ class Integer < Numeric
250
284
 
251
285
  # <!--
252
286
  # rdoc-file=numeric.c
253
- # - self - numeric -> numeric_result
287
+ # - self - other -> numeric
254
288
  # -->
255
- # Performs subtraction:
289
+ # Returns the difference of `self` and `other`:
256
290
  #
257
291
  # 4 - 2 # => 2
258
292
  # -4 - 2 # => -6
@@ -268,28 +302,34 @@ class Integer < Numeric
268
302
 
269
303
  # <!--
270
304
  # rdoc-file=numeric.rb
271
- # - -int -> integer
305
+ # - -self -> integer
272
306
  # -->
273
- # Returns `self`, negated.
307
+ # Returns `self`, negated:
308
+ #
309
+ # -1 # => -1
310
+ # -(-1) # => 1
311
+ # -0 # => 0
274
312
  #
275
313
  def -@: () -> Integer
276
314
 
277
315
  # <!--
278
316
  # rdoc-file=numeric.c
279
- # - self / numeric -> numeric_result
317
+ # - self / other -> numeric
280
318
  # -->
281
- # Performs division; for integer `numeric`, truncates the result to an integer:
319
+ # Returns the quotient of `self` and `other`.
320
+ #
321
+ # For integer `other`, truncates the result to an integer:
282
322
  #
283
- # 4 / 3 # => 1
284
- # 4 / -3 # => -2
285
- # -4 / 3 # => -2
286
- # -4 / -3 # => 1
323
+ # 4 / 3 # => 1
324
+ # 4 / -3 # => -2
325
+ # -4 / 3 # => -2
326
+ # -4 / -3 # => 1
287
327
  #
288
- # For other +numeric+, returns non-integer result:
328
+ # For non-integer `other`, returns a non-integer result:
289
329
  #
290
- # 4 / 3.0 # => 1.3333333333333333
291
- # 4 / Rational(3, 1) # => (4/3)
292
- # 4 / Complex(3, 0) # => ((4/3)+0i)
330
+ # 4 / 3.0 # => 1.3333333333333333
331
+ # 4 / Rational(3, 1) # => (4/3)
332
+ # 4 / Complex(3, 0) # => ((4/3)+0i)
293
333
  #
294
334
  def /: (Integer) -> Integer
295
335
  | (Float) -> Float
@@ -955,7 +995,7 @@ class Integer < Numeric
955
995
  def magnitude: () -> Integer
956
996
 
957
997
  # <!-- rdoc-file=numeric.c -->
958
- # Returns `self` modulo `other` as a real number.
998
+ # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
959
999
  #
960
1000
  # For integer `n` and real number `r`, these expressions are equivalent:
961
1001
  #
data/core/io/buffer.rbs CHANGED
@@ -131,18 +131,25 @@ 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_io` should be a `File` instance, opened for reading.
134
+ # `file` should be a `File` instance, opened for reading or reading and writing.
135
135
  #
136
- # Optional `size` and `offset` of mapping can be specified.
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.
137
139
  #
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.
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.
141
148
  #
142
149
  # File.write('test.txt', 'test')
143
150
  #
144
151
  # buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
145
- # # => #<IO::Buffer 0x00000001014a0000+4 MAPPED READONLY>
152
+ # # => #<IO::Buffer 0x00000001014a0000+4 EXTERNAL MAPPED FILE SHARED READONLY>
146
153
  #
147
154
  # buffer.readonly? # => true
148
155
  #
@@ -150,7 +157,7 @@ class IO
150
157
  # # => "test"
151
158
  #
152
159
  # buffer.set_string('b', 0)
153
- # # `set_string': Buffer is not writable! (IO::Buffer::AccessError)
160
+ # # 'IO::Buffer#set_string': Buffer is not writable! (IO::Buffer::AccessError)
154
161
  #
155
162
  # # create read/write mapping: length 4 bytes, offset 0, flags 0
156
163
  # buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0)
@@ -382,6 +389,10 @@ class IO
382
389
  # * `:U64`: unsigned integer, 8 bytes, big-endian
383
390
  # * `:s64`: signed integer, 8 bytes, little-endian
384
391
  # * `: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
385
396
  # * `:f32`: float, 4 bytes, little-endian
386
397
  # * `:F32`: float, 4 bytes, big-endian
387
398
  # * `:f64`: double, 8 bytes, little-endian
data/core/io/wait.rbs CHANGED
@@ -1,30 +1,9 @@
1
1
  %a{annotate:rdoc:skip}
2
2
  class IO
3
3
  # <!--
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
4
+ # rdoc-file=io.c
26
5
  # - io.wait(events, timeout) -> event mask, false or nil
27
- # - io.wait(timeout = nil, mode = :read) -> self, true, or false
6
+ # - io.wait(*event_symbols[, timeout]) -> self, true, or false
28
7
  # -->
29
8
  # Waits until the IO becomes ready for the specified events and returns the
30
9
  # subset of events that become ready, or a falsy value when times out.
@@ -32,11 +11,14 @@ class IO
32
11
  # The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
33
12
  # `IO::PRIORITY`.
34
13
  #
35
- # Returns a truthy value immediately when buffered data is available.
36
- #
37
- # Optional parameter `mode` is one of `:read`, `:write`, or `:read_write`.
14
+ # Returns an event mask (truthy value) immediately when buffered data is
15
+ # available.
38
16
  #
39
- # You must require 'io/wait' to use this method.
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.
40
22
  #
41
23
  def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
42
24
  | (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
@@ -44,7 +26,7 @@ class IO
44
26
  type wait_mode = :read | :r | :readable | :write | :w | :writable | :read_write | :rw | :readable_writable
45
27
 
46
28
  # <!--
47
- # rdoc-file=ext/io/wait/wait.c
29
+ # rdoc-file=io.c
48
30
  # - io.wait_readable -> truthy or falsy
49
31
  # - io.wait_readable(timeout) -> truthy or falsy
50
32
  # -->
@@ -52,19 +34,15 @@ class IO
52
34
  # times out. Returns a truthy value immediately when buffered data is
53
35
  # available.
54
36
  #
55
- # You must require 'io/wait' to use this method.
56
- #
57
37
  def wait_readable: (?Time::_Timeout? timeout) -> boolish
58
38
 
59
39
  # <!--
60
- # rdoc-file=ext/io/wait/wait.c
40
+ # rdoc-file=io.c
61
41
  # - io.wait_writable -> truthy or falsy
62
42
  # - io.wait_writable(timeout) -> truthy or falsy
63
43
  # -->
64
44
  # Waits until IO is writable and returns a truthy value or a falsy value when
65
45
  # times out.
66
46
  #
67
- # You must require 'io/wait' to use this method.
68
- #
69
47
  def wait_writable: (?Time::_Timeout? timeout) -> boolish
70
48
  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:format_specifications.rdoc).
1376
+ # Specifications](rdoc-ref:language/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:command_injection.rdoc).
2279
+ # [Command Injection](rdoc-ref:security/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:command_injection.rdoc).
2292
+ # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2293
2293
  #
2294
2294
  def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
2295
2295
 
@@ -2354,15 +2354,16 @@ 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:command_injection.rdoc).
2357
+ # input; see [Command Injection](rdoc-ref:security/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, and
2365
- # the block's value is assigned to global variable `$?` and returned.
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.
2366
2367
  #
2367
2368
  # Optional argument `mode` may be any valid IO mode. See [Access
2368
2369
  # Modes](rdoc-ref:File@Access+Modes).
@@ -2391,7 +2392,7 @@ class IO < Object
2391
2392
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
2392
2393
  # * Options for Kernel#spawn.
2393
2394
  #
2394
- # **Forked \Process**
2395
+ # **Forked Process**
2395
2396
  #
2396
2397
  # When argument `cmd` is the 1-character string `'-'`, causes the process to
2397
2398
  # fork:
@@ -2528,7 +2529,7 @@ class IO < Object
2528
2529
  #
2529
2530
  # When called from class IO (but not subclasses of IO), this method has
2530
2531
  # potential security vulnerabilities if called with untrusted input; see
2531
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2532
+ # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2532
2533
  #
2533
2534
  # The first argument must be a string that is the path to a file.
2534
2535
  #
@@ -2685,7 +2686,7 @@ class IO < Object
2685
2686
  #
2686
2687
  # When called from class IO (but not subclasses of IO), this method has
2687
2688
  # potential security vulnerabilities if called with untrusted input; see
2688
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2689
+ # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2689
2690
  #
2690
2691
  # The first argument must be a string that is the path to a file.
2691
2692
  #
@@ -2728,7 +2729,7 @@ class IO < Object
2728
2729
  #
2729
2730
  # When called from class IO (but not subclasses of IO), this method has
2730
2731
  # potential security vulnerabilities if called with untrusted input; see
2731
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2732
+ # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2732
2733
  #
2733
2734
  # The first argument must be a string that is the path to a file.
2734
2735
  #
@@ -2785,7 +2786,8 @@ class IO < Object
2785
2786
  # IO objects.
2786
2787
  #
2787
2788
  # Argument `timeout` is a numeric value (such as integer or float) timeout
2788
- # interval in seconds.
2789
+ # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
2790
+ # and `Float::INFINITY` means no timeout.
2789
2791
  #
2790
2792
  # The method monitors the IO objects given in all three arrays, waiting for some
2791
2793
  # to be ready; returns a 3-element array whose elements are:
@@ -2952,7 +2954,7 @@ class IO < Object
2952
2954
  #
2953
2955
  # When called from class IO (but not subclasses of IO), this method has
2954
2956
  # potential security vulnerabilities if called with untrusted input; see
2955
- # [Command Injection](rdoc-ref:command_injection.rdoc).
2957
+ # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2956
2958
  #
2957
2959
  # The first argument must be a string that is the path to a file.
2958
2960
  #
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 <tt.$stdout.putc(object)</tt> for the given object.
83
+ # * #putc: Equivalent to `$stdout.putc(object)` 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:command_injection.rdoc).
721
+ # input; see [Command Injection](rdoc-ref:security/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
- # $ $?.status # => 99>
728
+ # $ $?.exitstatus # => 99
729
729
  #
730
730
  # The built-in syntax `%x{...}` uses this method.
731
731
  #
@@ -777,6 +777,8 @@ 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
+ #
780
782
  def self?.autoload: (interned _module, String filename) -> NilClass
781
783
 
782
784
  # <!--
@@ -1116,7 +1118,7 @@ module Kernel : BasicObject
1116
1118
  # Returns the string resulting from formatting `objects` into `format_string`.
1117
1119
  #
1118
1120
  # For details on `format_string`, see [Format
1119
- # Specifications](rdoc-ref:format_specifications.rdoc).
1121
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1120
1122
  #
1121
1123
  def self?.format: (String format, *untyped args) -> String
1122
1124
 
@@ -1127,7 +1129,7 @@ module Kernel : BasicObject
1127
1129
  # Returns the string resulting from formatting `objects` into `format_string`.
1128
1130
  #
1129
1131
  # For details on `format_string`, see [Format
1130
- # Specifications](rdoc-ref:format_specifications.rdoc).
1132
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1131
1133
  #
1132
1134
  alias sprintf format
1133
1135
 
@@ -1218,6 +1220,7 @@ module Kernel : BasicObject
1218
1220
  # loop do
1219
1221
  # print "Input: "
1220
1222
  # line = gets
1223
+ # # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
1221
1224
  # break if !line or line =~ /^q/i
1222
1225
  # # ...
1223
1226
  # end
@@ -1246,7 +1249,7 @@ module Kernel : BasicObject
1246
1249
  # Creates an IO object connected to the given file.
1247
1250
  #
1248
1251
  # This method has potential security vulnerabilities if called with untrusted
1249
- # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
1252
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1250
1253
  #
1251
1254
  # With no block given, file stream is returned:
1252
1255
  #
@@ -1324,7 +1327,7 @@ module Kernel : BasicObject
1324
1327
  # io.write(sprintf(format_string, *objects))
1325
1328
  #
1326
1329
  # For details on `format_string`, see [Format
1327
- # Specifications](rdoc-ref:format_specifications.rdoc).
1330
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
1328
1331
  #
1329
1332
  # With the single argument `format_string`, formats `objects` into the string,
1330
1333
  # then writes the formatted string to $stdout:
@@ -1463,7 +1466,9 @@ module Kernel : BasicObject
1463
1466
  # Kernel.srand may be used to ensure that sequences of random numbers are
1464
1467
  # reproducible between different runs of a program.
1465
1468
  #
1466
- # See also Random.rand.
1469
+ # Related: Random.rand.
1470
+ # rand(100.0) # => 64 (Integer because max.to_i is 100)
1471
+ # Random.rand(100.0) # => 30.315320967824523
1467
1472
  #
1468
1473
  def self?.rand: (?0) -> Float
1469
1474
  | (int arg0) -> Integer
@@ -1585,7 +1590,8 @@ module Kernel : BasicObject
1585
1590
  # IO objects.
1586
1591
  #
1587
1592
  # Argument `timeout` is a numeric value (such as integer or float) timeout
1588
- # interval in seconds.
1593
+ # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
1594
+ # and `Float::INFINITY` means no timeout.
1589
1595
  #
1590
1596
  # The method monitors the IO objects given in all three arrays, waiting for some
1591
1597
  # to be ready; returns a 3-element array whose elements are:
@@ -1773,58 +1779,58 @@ module Kernel : BasicObject
1773
1779
  # * Each of these tests operates only on the entity at `path0`,
1774
1780
  # and returns `true` or `false`;
1775
1781
  # for a non-existent entity, returns `false` (does not raise exception):
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.
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.
1799
1805
  # * This test operates only on the entity at `path0`,
1800
1806
  # and returns an integer size or `nil`:
1801
- # Character |Test
1802
- # ------------|--------------------------------------------------------------------------------------------
1803
- # <tt>'s'</tt>|Returns positive integer size if the entity exists and has non-zero length, +nil+ otherwise.
1807
+ # Character|Test
1808
+ # ---------|--------------------------------------------------------------------------------------------
1809
+ # `'s'` |Returns positive integer size if the entity exists and has non-zero length, `nil` otherwise.
1804
1810
  # * Each of these tests operates only on the entity at `path0`,
1805
1811
  # and returns a Time object;
1806
1812
  # raises an exception if the entity does not exist:
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.
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.
1812
1818
  # * Each of these tests operates on the modification time (`mtime`)
1813
1819
  # of each of the entities at `path0` and `path1`,
1814
1820
  # and returns a `true` or `false`;
1815
1821
  # returns `false` if either entity does not exist:
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`.
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`.
1821
1827
  # * This test operates on the content of each of the entities at `path0` and
1822
1828
  # `path1`,
1823
1829
  # and returns a `true` or `false`;
1824
1830
  # returns `false` if either entity does not exist:
1825
- # Character |Test
1826
- # ------------|---------------------------------------------
1827
- # <tt>'-'</tt>|Whether the entities exist and are identical.
1831
+ # Character|Test
1832
+ # ---------|---------------------------------------------
1833
+ # `'-'` |Whether the entities exist and are identical.
1828
1834
  #
1829
1835
  def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
1830
1836
 
@@ -1901,7 +1907,7 @@ module Kernel : BasicObject
1901
1907
  # * Invoking the executable at `exe_path`.
1902
1908
  #
1903
1909
  # This method has potential security vulnerabilities if called with untrusted
1904
- # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
1910
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1905
1911
  #
1906
1912
  # The new process is created using the [exec system
1907
1913
  # call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
@@ -1993,7 +1999,7 @@ module Kernel : BasicObject
1993
1999
  # * Invoking the executable at `exe_path`.
1994
2000
  #
1995
2001
  # This method has potential security vulnerabilities if called with untrusted
1996
- # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
2002
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
1997
2003
  #
1998
2004
  # Returns the process ID (pid) of the new process, without waiting for it to
1999
2005
  # complete.
@@ -2096,7 +2102,7 @@ module Kernel : BasicObject
2096
2102
  # * Invoking the executable at `exe_path`.
2097
2103
  #
2098
2104
  # This method has potential security vulnerabilities if called with untrusted
2099
- # input; see [Command Injection](rdoc-ref:command_injection.rdoc).
2105
+ # input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
2100
2106
  #
2101
2107
  # Returns:
2102
2108
  #
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, Data, Method, UnboundMethod, Proc, Thread,
150
+ # * an instance of MatchData, 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 "Special global variables" section in Regexp documentation.
44
+ # See also Regexp@Global+Variables.
45
45
  #
46
46
  class MatchData
47
47
  type capture = String | Symbol | int