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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
@@ -28,7 +28,7 @@
28
28
  # * `match_values_cleared?(scanner)`:
29
29
  # Returns whether the scanner's [match
30
30
  # values](rdoc-ref:StringScanner@Match+Values) are cleared.
31
- # See examples [[here]](ext/strscan/helper_methods_md.html).
31
+ # See examples at [helper methods](helper_methods.md).
32
32
  # ## The `StringScanner` Object
33
33
  # This code creates a `StringScanner` object
34
34
  # (we'll call it simply a *scanner*),
@@ -85,10 +85,10 @@
85
85
  # and a zero-based *character position*.
86
86
  # Each of these methods explicitly sets positions:
87
87
  # Method | Effect
88
- # ------------------------|--------------------------------------------------------
89
- # #reset |Sets both positions to zero (begining of stored string).
88
+ # ------------------------|---------------------------------------------------------
89
+ # #reset |Sets both positions to zero (beginning of stored string).
90
90
  # #terminate | Sets both positions to the end of the stored string.
91
- # #pos=(new_byte_position)| Sets byte position; adjusts character position.
91
+ # #pos=(new_byte_position)| Sets byte position; adjusts character position.
92
92
  # ### Byte Position (Position)
93
93
  # The byte position (or simply *position*)
94
94
  # is a zero-based index into the bytes in the scanner's stored string;
@@ -159,7 +159,7 @@
159
159
  # # rest_size: 12
160
160
  #
161
161
  # ## Target Substring
162
- # The target substring is the the part of the [stored
162
+ # The target substring is the part of the [stored
163
163
  # string](rdoc-ref:StringScanner@Stored+String)
164
164
  # that extends from the current [byte
165
165
  # position](rdoc-ref:StringScanner@Byte+Position+-28Position-29) to the end of
@@ -211,12 +211,12 @@
211
211
  # This table summarizes (details and examples at the links):
212
212
  # Method | Returns |Sets Match Values?
213
213
  # ---------------------|---------------------------------------------|------------------
214
- # #check(pattern) | Matched leading substring or +nil+. | Yes.
215
- # #check_until(pattern)| Matched substring (anywhere) or +nil+. | Yes.
214
+ # #check(pattern) | Matched leading substring or `nil`. | Yes.
215
+ # #check_until(pattern)| Matched substring (anywhere) or `nil`. | Yes.
216
216
  # #exist?(pattern) | Matched substring (anywhere) end index. | Yes.
217
- # #match?(pattern) | Size of matched leading substring or +nil+. | Yes.
217
+ # #match?(pattern) | Size of matched leading substring or `nil`. | Yes.
218
218
  # #peek(size) | Leading substring of given length (bytes). | No.
219
- # #peek_byte | Integer leading byte or +nil+. | No.
219
+ # #peek_byte | Integer leading byte or `nil`. | No.
220
220
  # #rest |Target substring (from byte position to end).| No.
221
221
  # ### Traversing the Target Substring
222
222
  # A *traversal* method examines the target substring,
@@ -226,24 +226,24 @@
226
226
  # This table summarizes (details and examples at links):
227
227
  # Method | Returns |Sets Match Values?
228
228
  # --------------------|----------------------------------------------------|------------------
229
- # #get_byte | Leading byte or +nil+. | No.
230
- # #getch | Leading character or +nil+. | No.
231
- # #scan(pattern) | Matched leading substring or +nil+. | Yes.
232
- # #scan_byte | Integer leading byte or +nil+. | No.
233
- # #scan_until(pattern)| Matched substring (anywhere) or +nil+. | Yes.
234
- # #skip(pattern) | Matched leading substring size or +nil+. | Yes.
235
- # #skip_until(pattern)|Position delta to end-of-matched-substring or +nil+.| Yes.
236
- # #unscan | +self+. | No.
229
+ # #get_byte | Leading byte or `nil`. | No.
230
+ # #getch | Leading character or `nil`. | No.
231
+ # #scan(pattern) | Matched leading substring or `nil`. | Yes.
232
+ # #scan_byte | Integer leading byte or `nil`. | No.
233
+ # #scan_until(pattern)| Matched substring (anywhere) or `nil`. | Yes.
234
+ # #skip(pattern) | Matched leading substring size or `nil`. | Yes.
235
+ # #skip_until(pattern)|Position delta to end-of-matched-substring or `nil`.| Yes.
236
+ # #unscan | `self`. | No.
237
237
  # ## Querying the Scanner
238
238
  # Each of these methods queries the scanner object
239
239
  # without modifying it (details and examples at links)
240
240
  # Method | Returns
241
241
  # -------------------|--------------------------------
242
- # #beginning_of_line?| +true+ or +false+.
242
+ # #beginning_of_line?| `true` or `false`.
243
243
  # #charpos | Character position.
244
- # #eos? | +true+ or +false+.
245
- # #fixed_anchor? | +true+ or +false+.
246
- # #inspect |String representation of +self+.
244
+ # #eos? | `true` or `false`.
245
+ # #fixed_anchor? | `true` or `false`.
246
+ # #inspect |String representation of `self`.
247
247
  # #pos | Byte position.
248
248
  # #rest | Target substring.
249
249
  # #rest_size | Size of target substring.
@@ -312,11 +312,11 @@
312
312
  # Each of these methods returns a basic match value:
313
313
  # Method | Return After Match |Return After No Match
314
314
  # -------------|--------------------------------------|---------------------
315
- # #matched? | +true+. | +false+.
316
- # #matched_size| Size of matched substring. | +nil+.
317
- # #matched | Matched substring. | +nil+.
318
- # #pre_match |Substring preceding matched substring.| +nil+.
319
- # #post_match |Substring following matched substring.| +nil+.
315
+ # #matched? | `true`. | `false`.
316
+ # #matched_size| Size of matched substring. | `nil`.
317
+ # #matched | Matched substring. | `nil`.
318
+ # #pre_match |Substring preceding matched substring.| `nil`.
319
+ # #post_match |Substring following matched substring.| `nil`.
320
320
  #
321
321
  # See examples below.
322
322
  # #### Captured Match Values
@@ -326,11 +326,11 @@
326
326
  # Each of these methods returns a captured match value:
327
327
  # Method | Return After Match |Return After No Match
328
328
  # ---------------|---------------------------------------|---------------------
329
- # #size | Count of captured substrings. | +nil+.
330
- # #[](n) | <tt>n</tt>th captured substring. | +nil+.
331
- # #captures | Array of all captured substrings. | +nil+.
332
- # #values_at(*n) |Array of specified captured substrings.| +nil+.
333
- # #named_captures| Hash of named captures. | <tt>{}</tt>.
329
+ # #size | Count of captured substrings. | `nil`.
330
+ # #[](n) | `n`th captured substring. | `nil`.
331
+ # #captures | Array of all captured substrings. | `nil`.
332
+ # #values_at(*n) |Array of specified captured substrings.| `nil`.
333
+ # #named_captures| Hash of named captures. | `{}`.
334
334
  #
335
335
  # See examples below.
336
336
  # #### Match Values Examples
@@ -19,7 +19,7 @@
19
19
  # require 'tempfile'
20
20
  #
21
21
  # # Tempfile.create with a block
22
- # # The filename are choosen automatically.
22
+ # # The filename are chosen automatically.
23
23
  # # (You can specify the prefix and suffix of the filename by an optional argument.)
24
24
  # Tempfile.create {|f|
25
25
  # f.puts "foo"
@@ -248,8 +248,8 @@ class Tempfile < File
248
248
  #
249
249
  # Implementation note:
250
250
  #
251
- # The keyword argument +anonymous=true+ is implemented using FILE_SHARE_DELETE
252
- # on Windows. O_TMPFILE is used on Linux.
251
+ # The keyword argument `anonymous=true` is implemented using `FILE_SHARE_DELETE`
252
+ # on Windows. `O_TMPFILE` is used on Linux.
253
253
  #
254
254
  # Related: Tempfile.new.
255
255
  #
@@ -10,7 +10,7 @@ class Time
10
10
 
11
11
  # <!--
12
12
  # rdoc-file=lib/time.rb
13
- # - zone_offset(zone, year=self.now.year)
13
+ # - zone_offset(zone, year=nil)
14
14
  # -->
15
15
  # Return the number of seconds the specified time zone differs from UTC.
16
16
  #
@@ -26,7 +26,7 @@ module Timeout
26
26
  # rdoc-file=lib/timeout.rb
27
27
  # - timeout(sec, klass = nil, message = nil) { |sec| ... }
28
28
  # -->
29
- # Perform an operation in a block, raising an error if it takes longer than
29
+ # Perform an operation in a block, raising an exception if it takes longer than
30
30
  # `sec` seconds to complete.
31
31
  #
32
32
  # `sec`
@@ -45,12 +45,20 @@ module Timeout
45
45
  #
46
46
  #
47
47
  # Returns the result of the block **if** the block completed before `sec`
48
- # seconds, otherwise throws an exception, based on the value of `klass`.
48
+ # seconds, otherwise raises an exception, based on the value of `klass`.
49
49
  #
50
- # The exception thrown to terminate the given block cannot be rescued inside the
51
- # block unless `klass` is given explicitly. However, the block can use ensure to
52
- # prevent the handling of the exception. For that reason, this method cannot be
53
- # relied on to enforce timeouts for untrusted blocks.
50
+ # The exception raised to terminate the given block is the given `klass`, or
51
+ # Timeout::ExitException if `klass` is not given. The reason for that behavior
52
+ # is that Timeout::Error inherits from RuntimeError and might be caught
53
+ # unexpectedly by `rescue`. Timeout::ExitException inherits from Exception so it
54
+ # will only be rescued by `rescue Exception`. Note that the
55
+ # Timeout::ExitException is translated to a Timeout::Error once it reaches the
56
+ # Timeout.timeout call, so outside that call it will be a Timeout::Error.
57
+ #
58
+ # In general, be aware that the code block may rescue the exception, and in such
59
+ # a case not respect the timeout. Also, the block can use `ensure` to prevent
60
+ # the handling of the exception. For those reasons, this method cannot be relied
61
+ # on to enforce timeouts for untrusted blocks.
54
62
  #
55
63
  # If a scheduler is defined, it will be used to handle the timeout by invoking
56
64
  # Scheduler#timeout_after.
@@ -59,11 +67,59 @@ module Timeout
59
67
  # Timeout` into your classes so they have a #timeout method, as well as a module
60
68
  # method, so you can call it directly as Timeout.timeout().
61
69
  #
70
+ # #### Ensuring the exception does not fire inside ensure blocks
71
+ #
72
+ # When using Timeout.timeout it can be desirable to ensure the timeout exception
73
+ # does not fire inside an `ensure` block. The simplest and best way to do so it
74
+ # to put the Timeout.timeout call inside the body of the begin/ensure/end:
75
+ #
76
+ # begin
77
+ # Timeout.timeout(sec) { some_long_operation }
78
+ # ensure
79
+ # cleanup # safe, cannot be interrupt by timeout
80
+ # end
81
+ #
82
+ # If that is not feasible, e.g. if there are `ensure` blocks inside
83
+ # `some_long_operation`, they need to not be interrupted by timeout, and it's
84
+ # not possible to move these ensure blocks outside, one can use
85
+ # Thread.handle_interrupt to delay the timeout exception like so:
86
+ #
87
+ # Thread.handle_interrupt(Timeout::Error => :never) {
88
+ # Timeout.timeout(sec, Timeout::Error) do
89
+ # setup # timeout cannot happen here, no matter how long it takes
90
+ # Thread.handle_interrupt(Timeout::Error => :immediate) {
91
+ # some_long_operation # timeout can happen here
92
+ # }
93
+ # ensure
94
+ # cleanup # timeout cannot happen here, no matter how long it takes
95
+ # end
96
+ # }
97
+ #
98
+ # An important thing to note is the need to pass an exception klass to
99
+ # Timeout.timeout, otherwise it does not work. Specifically, using
100
+ # +Thread.handle_interrupt(Timeout::ExitException => ...)+ is unsupported and
101
+ # causes subtle errors like raising the wrong exception outside the block, do
102
+ # not use that.
103
+ #
104
+ # Note that Thread.handle_interrupt is somewhat dangerous because if setup or
105
+ # cleanup hangs then the current thread will hang too and the timeout will never
106
+ # fire. Also note the block might run for longer than `sec` seconds: e.g.
107
+ # some_long_operation executes for `sec` seconds + whatever time cleanup takes.
108
+ #
109
+ # If you want the timeout to only happen on blocking operations one can use
110
+ # :on_blocking instead of :immediate. However, that means if the block uses no
111
+ # blocking operations after `sec` seconds, the block will not be interrupted.
112
+ # ----
113
+ # <!--
114
+ # rdoc-file=lib/timeout.rb
115
+ # - timeout(*args, &block)
116
+ # -->
117
+ #
62
118
  def self?.timeout: [T] (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> T } -> T
63
119
  end
64
120
 
65
121
  # <!-- rdoc-file=lib/timeout.rb -->
66
- # Internal error raised to when a timeout is triggered.
122
+ # Internal exception raised to when a timeout is triggered.
67
123
  #
68
124
  class Timeout::ExitException < Exception
69
125
  end
@@ -1,5 +1,8 @@
1
1
  %a{annotate:rdoc:skip}
2
2
  module TSort[Node]
3
+ # <!-- rdoc-file=lib/tsort.rb -->
4
+ # Exception class to be raised when a cycle is found.
5
+ #
3
6
  class Cyclic < StandardError
4
7
  end
5
8
  end
@@ -420,8 +420,8 @@ module URI
420
420
  # URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
421
421
  # # => #<URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
422
422
  #
423
- # It's recommended to first ::escape string `uri` if it may contain invalid URI
424
- # characters.
423
+ # It's recommended to first URI::RFC2396_PARSER.escape string `uri` if it may
424
+ # contain invalid URI characters.
425
425
  #
426
426
  def self.parse: (_ToStr uri) -> (File | FTP | HTTP | HTTPS | LDAP | LDAPS | MailTo | WS | WSS | Generic)
427
427
 
@@ -535,6 +535,9 @@ URI::ABS_URI: Regexp
535
535
 
536
536
  URI::ABS_URI_REF: Regexp
537
537
 
538
+ # <!-- rdoc-file=lib/uri/common.rb -->
539
+ # The default parser instance.
540
+ #
538
541
  URI::DEFAULT_PARSER: URI::RFC2396_Parser
539
542
 
540
543
  URI::ESCAPED: Regexp
@@ -557,6 +560,14 @@ URI::REL_URI: Regexp
557
560
 
558
561
  URI::REL_URI_REF: Regexp
559
562
 
563
+ # <!-- rdoc-file=lib/uri/common.rb -->
564
+ # The default parser instance for RFC 2396.
565
+ #
566
+ URI::RFC2396_PARSER: URI::RFC2396_Parser
567
+
568
+ # <!-- rdoc-file=lib/uri/common.rb -->
569
+ # The default parser instance for RFC 3986.
570
+ #
560
571
  URI::RFC3986_PARSER: URI::RFC3986_Parser
561
572
 
562
573
  URI::SCHEME: Regexp
@@ -588,6 +599,7 @@ module Kernel
588
599
  # Returns a URI object derived from the given `uri`, which may be a URI string
589
600
  # or an existing URI object:
590
601
  #
602
+ # require 'uri'
591
603
  # # Returns a new URI.
592
604
  # uri = URI('http://github.com/ruby/ruby')
593
605
  # # => #<URI::HTTP http://github.com/ruby/ruby>
@@ -595,5 +607,7 @@ module Kernel
595
607
  # URI(uri)
596
608
  # # => #<URI::HTTP http://github.com/ruby/ruby>
597
609
  #
610
+ # You must require 'uri' to use this method.
611
+ #
598
612
  def self?.URI: (URI::Generic | String uri) -> URI::Generic
599
613
  end
@@ -43,7 +43,7 @@ module URI
43
43
  # :path => '/ruby/src'})
44
44
  # uri2.to_s # => "file://host.example.com/ruby/src"
45
45
  #
46
- # uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')})
46
+ # uri3 = URI::File.build({:path => URI::RFC2396_PARSER.escape('/path/my file.txt')})
47
47
  # uri3.to_s # => "file:///path/my%20file.txt"
48
48
  #
49
49
  def self.build: (Array[String] args) -> URI::File
@@ -145,7 +145,7 @@ module URI
145
145
  #
146
146
  # At first, tries to create a new URI::Generic instance using
147
147
  # URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
148
- # then it does URI::Escape.escape all URI components and tries again.
148
+ # then it does URI::RFC2396_PARSER.escape all URI components and tries again.
149
149
  #
150
150
  def self.build2: (Array[nil | String | Integer]) -> URI::Generic
151
151
  | ({ scheme: String?, userinfo: String?, host: String?, port: Integer?, registry: String?, path: String?, opaque: String?, query: String?, fragment: String? }) -> instance
@@ -293,7 +293,7 @@ module URI
293
293
  # -->
294
294
  # Returns the parser to be used.
295
295
  #
296
- # Unless a URI::Parser is defined, DEFAULT_PARSER is used.
296
+ # Unless the `parser` is defined, DEFAULT_PARSER is used.
297
297
  #
298
298
  def parser: () -> untyped
299
299
 
@@ -317,7 +317,7 @@ module URI
317
317
  # rdoc-file=lib/uri/generic.rb
318
318
  # - check_scheme(v)
319
319
  # -->
320
- # Checks the scheme `v` component against the URI::Parser Regexp for :SCHEME.
320
+ # Checks the scheme `v` component against the `parser` Regexp for :SCHEME.
321
321
  #
322
322
  def check_scheme: (String? v) -> true
323
323
 
@@ -374,8 +374,8 @@ module URI
374
374
  # rdoc-file=lib/uri/generic.rb
375
375
  # - check_user(v)
376
376
  # -->
377
- # Checks the user `v` component for RFC2396 compliance and against the
378
- # URI::Parser Regexp for :USERINFO.
377
+ # Checks the user `v` component for RFC2396 compliance and against the `parser`
378
+ # Regexp for :USERINFO.
379
379
  #
380
380
  # Can not have a registry or opaque component defined, with a user component
381
381
  # defined.
@@ -387,7 +387,7 @@ module URI
387
387
  # - check_password(v, user = @user)
388
388
  # -->
389
389
  # Checks the password `v` component for RFC2396 compliance and against the
390
- # URI::Parser Regexp for :USERINFO.
390
+ # `parser` Regexp for :USERINFO.
391
391
  #
392
392
  # Can not have a registry or opaque component defined, with a user component
393
393
  # defined.
@@ -424,7 +424,7 @@ module URI
424
424
  #
425
425
  # uri = URI.parse("http://john:S3nsit1ve@my.example.com")
426
426
  # uri.user = "sam"
427
- # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
427
+ # uri.to_s #=> "http://sam@my.example.com"
428
428
  #
429
429
  def user=: (String? user) -> String?
430
430
 
@@ -530,8 +530,8 @@ module URI
530
530
  # rdoc-file=lib/uri/generic.rb
531
531
  # - check_host(v)
532
532
  # -->
533
- # Checks the host `v` component for RFC2396 compliance and against the
534
- # URI::Parser Regexp for :HOST.
533
+ # Checks the host `v` component for RFC2396 compliance and against the `parser`
534
+ # Regexp for :HOST.
535
535
  #
536
536
  # Can not have a registry or opaque component defined, with a host component
537
537
  # defined.
@@ -611,8 +611,8 @@ module URI
611
611
  # rdoc-file=lib/uri/generic.rb
612
612
  # - check_port(v)
613
613
  # -->
614
- # Checks the port `v` component for RFC2396 compliance and against the
615
- # URI::Parser Regexp for :PORT.
614
+ # Checks the port `v` component for RFC2396 compliance and against the `parser`
615
+ # Regexp for :PORT.
616
616
  #
617
617
  # Can not have a registry or opaque component defined, with a port component
618
618
  # defined.
@@ -670,8 +670,8 @@ module URI
670
670
  # rdoc-file=lib/uri/generic.rb
671
671
  # - check_path(v)
672
672
  # -->
673
- # Checks the path `v` component for RFC2396 compliance and against the
674
- # URI::Parser Regexp for :ABS_PATH and :REL_PATH.
673
+ # Checks the path `v` component for RFC2396 compliance and against the `parser`
674
+ # Regexp for :ABS_PATH and :REL_PATH.
675
675
  #
676
676
  # Can not have a opaque component defined, with a path component defined.
677
677
  #
@@ -742,7 +742,7 @@ module URI
742
742
  # - check_opaque(v)
743
743
  # -->
744
744
  # Checks the opaque `v` component for RFC2396 compliance and against the
745
- # URI::Parser Regexp for :OPAQUE.
745
+ # `parser` Regexp for :OPAQUE.
746
746
  #
747
747
  # Can not have a host, port, user, or path component defined, with an opaque
748
748
  # component defined.
@@ -781,8 +781,7 @@ module URI
781
781
  # rdoc-file=lib/uri/generic.rb
782
782
  # - fragment=(v)
783
783
  # -->
784
- # Checks the fragment `v` component against the URI::Parser Regexp for
785
- # :FRAGMENT.
784
+ # Checks the fragment `v` component against the `parser` Regexp for :FRAGMENT.
786
785
  #
787
786
  # ## Args
788
787
  #
@@ -910,6 +909,13 @@ module URI
910
909
  #
911
910
  def merge: (URI::Generic | string oth) -> URI::Generic
912
911
 
912
+ # <!--
913
+ # rdoc-file=lib/uri/generic.rb
914
+ # - +(oth)
915
+ # -->
916
+ #
917
+ alias + merge
918
+
913
919
  # :stopdoc:
914
920
  def route_from_path: (String src, String dst) -> String
915
921
 
@@ -1010,6 +1016,7 @@ module URI
1010
1016
  # rdoc-file=lib/uri/generic.rb
1011
1017
  # - hash()
1012
1018
  # -->
1019
+ # Returns the hash value.
1013
1020
  #
1014
1021
  def hash: () -> Integer
1015
1022
 
@@ -1017,6 +1024,7 @@ module URI
1017
1024
  # rdoc-file=lib/uri/generic.rb
1018
1025
  # - eql?(oth)
1019
1026
  # -->
1027
+ # Compares with *oth* for Hash.
1020
1028
  #
1021
1029
  def eql?: (URI::Generic oth) -> bool
1022
1030
 
@@ -17,14 +17,14 @@ module URI
17
17
  # <!-- rdoc-file=lib/uri/rfc2396_parser.rb -->
18
18
  # The Hash of patterns.
19
19
  #
20
- # See also URI::Parser.initialize_pattern.
20
+ # See also #initialize_pattern.
21
21
  #
22
22
  attr_reader pattern: Hash[Symbol, String]
23
23
 
24
24
  # <!-- rdoc-file=lib/uri/rfc2396_parser.rb -->
25
25
  # The Hash of Regexp.
26
26
  #
27
- # See also URI::Parser.initialize_regexp.
27
+ # See also #initialize_regexp.
28
28
  #
29
29
  attr_reader regexp: Hash[Symbol, Regexp]
30
30
 
@@ -34,7 +34,7 @@ module URI
34
34
  # -->
35
35
  # ## Synopsis
36
36
  #
37
- # URI::Parser.new([opts])
37
+ # URI::RFC2396_Parser.new([opts])
38
38
  #
39
39
  # ## Args
40
40
  #
@@ -52,7 +52,7 @@ module URI
52
52
  #
53
53
  # ## Examples
54
54
  #
55
- # p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
55
+ # p = URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
56
56
  # u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
57
57
  # URI.parse(u.to_s) #=> raises URI::InvalidURIError
58
58
  #
@@ -105,7 +105,7 @@ module URI
105
105
  # Attempts to parse and merge a set of URIs. If no `block` given, then returns
106
106
  # the result, else it calls `block` for each element in result.
107
107
  #
108
- # See also URI::Parser.make_regexp.
108
+ # See also #make_regexp.
109
109
  #
110
110
  def extract: (String str, ?Array[String] schemes) -> Array[String]
111
111
  | (String str, ?Array[String] schemes) { (String) -> untyped } -> nil
@@ -152,8 +152,7 @@ module URI
152
152
  #
153
153
  # ## Usage
154
154
  #
155
- # p = URI::Parser.new
156
- # p.parse("ldap://ldap.example.com/dc=example?user=john")
155
+ # URI::RFC2396_PARSER.parse("ldap://ldap.example.com/dc=example?user=john")
157
156
  # #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
158
157
  #
159
158
  def parse: (String uri) -> URI::Generic
@@ -62,8 +62,8 @@ module Zlib
62
62
  # GzipReader object associated with that file. Further details of this method
63
63
  # are in Zlib::GzipReader.new and ZLib::GzipFile.wrap.
64
64
  #
65
- def self.open: (String | _ToPath filename) -> instance
66
- | (String | _ToPath filename) { (instance gz) -> void } -> void
65
+ def self.open: (path filename) -> instance
66
+ | (path filename) { (instance gz) -> void } -> void
67
67
 
68
68
  # <!--
69
69
  # rdoc-file=ext/zlib/zlib.c
@@ -83,7 +83,7 @@ module Zlib
83
83
  # compression started. Setting a value of 0 indicates no time stamp is
84
84
  # available.
85
85
  #
86
- def mtime=: (string | _ToPath | IO file_name) -> Time
86
+ def mtime=: (path | IO file_name) -> Time
87
87
 
88
88
  # <!--
89
89
  # rdoc-file=ext/zlib/zlib.c
@@ -153,6 +153,7 @@ module Zlib
153
153
  # rdoc-file=ext/zlib/zlib.c
154
154
  # - flush_next_in -> input
155
155
  # -->
156
+ # Flushes input buffer and returns all data in that buffer.
156
157
  #
157
158
  def flush_next_in: () -> String
158
159
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.dev.4
4
+ version: 4.0.0.dev.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: logger
@@ -37,6 +37,20 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 1.3.0
40
+ - !ruby/object:Gem::Dependency
41
+ name: tsort
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
40
54
  description: RBS is the language for type signatures for Ruby and standard library
41
55
  definitions.
42
56
  email:
@@ -50,11 +64,13 @@ files:
50
64
  - ".clang-format"
51
65
  - ".clangd"
52
66
  - ".github/dependabot.yml"
67
+ - ".github/workflows/bundle-update.yml"
53
68
  - ".github/workflows/c-check.yml"
54
69
  - ".github/workflows/comments.yml"
55
70
  - ".github/workflows/dependabot.yml"
56
71
  - ".github/workflows/ruby.yml"
57
72
  - ".github/workflows/typecheck.yml"
73
+ - ".github/workflows/valgrind.yml"
58
74
  - ".github/workflows/windows.yml"
59
75
  - ".gitignore"
60
76
  - ".rubocop.yml"
@@ -80,6 +96,7 @@ files:
80
96
  - core/encoding.rbs
81
97
  - core/enumerable.rbs
82
98
  - core/enumerator.rbs
99
+ - core/enumerator/arithmetic_sequence.rbs
83
100
  - core/enumerator/product.rbs
84
101
  - core/env.rbs
85
102
  - core/errno.rbs
@@ -109,6 +126,7 @@ files:
109
126
  - core/object.rbs
110
127
  - core/object_space.rbs
111
128
  - core/object_space/weak_key_map.rbs
129
+ - core/pathname.rbs
112
130
  - core/proc.rbs
113
131
  - core/process.rbs
114
132
  - core/ractor.rbs
@@ -121,6 +139,7 @@ files:
121
139
  - core/rbs/unnamed/random.rbs
122
140
  - core/refinement.rbs
123
141
  - core/regexp.rbs
142
+ - core/ruby.rbs
124
143
  - core/ruby_vm.rbs
125
144
  - core/rubygems/basic_specification.rbs
126
145
  - core/rubygems/config_file.rbs
@@ -150,16 +169,20 @@ files:
150
169
  - core/unbound_method.rbs
151
170
  - core/warning.rbs
152
171
  - docs/CONTRIBUTING.md
172
+ - docs/aliases.md
153
173
  - docs/architecture.md
154
174
  - docs/collection.md
155
175
  - docs/data_and_struct.md
176
+ - docs/encoding.md
156
177
  - docs/gem.md
178
+ - docs/inline.md
157
179
  - docs/rbs_by_example.md
158
180
  - docs/repo.md
159
181
  - docs/sigs.md
160
182
  - docs/stdlib.md
161
183
  - docs/syntax.md
162
184
  - docs/tools.md
185
+ - docs/type_fingerprint.md
163
186
  - exe/rbs
164
187
  - ext/rbs_extension/ast_translation.c
165
188
  - ext/rbs_extension/ast_translation.h
@@ -409,6 +432,7 @@ files:
409
432
  - stdlib/bigdecimal-math/0/big_math.rbs
410
433
  - stdlib/bigdecimal-math/0/manifest.yaml
411
434
  - stdlib/bigdecimal/0/big_decimal.rbs
435
+ - stdlib/cgi-escape/0/escape.rbs
412
436
  - stdlib/cgi/0/core.rbs
413
437
  - stdlib/cgi/0/manifest.yaml
414
438
  - stdlib/coverage/0/coverage.rbs
@@ -504,6 +528,7 @@ files:
504
528
  - stdlib/psych/0/psych.rbs
505
529
  - stdlib/psych/0/store.rbs
506
530
  - stdlib/pty/0/pty.rbs
531
+ - stdlib/random-formatter/0/random-formatter.rbs
507
532
  - stdlib/rdoc/0/code_object.rbs
508
533
  - stdlib/rdoc/0/comment.rbs
509
534
  - stdlib/rdoc/0/context.rbs
@@ -517,6 +542,7 @@ files:
517
542
  - stdlib/resolv/0/manifest.yaml
518
543
  - stdlib/resolv/0/resolv.rbs
519
544
  - stdlib/ripper/0/ripper.rbs
545
+ - stdlib/securerandom/0/manifest.yaml
520
546
  - stdlib/securerandom/0/securerandom.rbs
521
547
  - stdlib/shellwords/0/shellwords.rbs
522
548
  - stdlib/singleton/0/singleton.rbs
@@ -589,14 +615,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
589
615
  requirements:
590
616
  - - ">="
591
617
  - !ruby/object:Gem::Version
592
- version: '3.1'
618
+ version: '3.2'
593
619
  required_rubygems_version: !ruby/object:Gem::Requirement
594
620
  requirements:
595
621
  - - ">="
596
622
  - !ruby/object:Gem::Version
597
623
  version: '0'
598
624
  requirements: []
599
- rubygems_version: 3.6.2
625
+ rubygems_version: 3.6.9
600
626
  specification_version: 4
601
627
  summary: Type signature for Ruby.
602
628
  test_files: []