rbs 2.5.1 → 2.6.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +1 -1
  3. data/.github/workflows/ruby.yml +3 -3
  4. data/CHANGELOG.md +44 -0
  5. data/Gemfile.lock +5 -5
  6. data/Rakefile +6 -38
  7. data/Steepfile +6 -2
  8. data/core/constants.rbs +1 -1
  9. data/core/env.rbs +1 -1323
  10. data/core/global_variables.rbs +1 -1
  11. data/core/hash.rbs +3 -3
  12. data/core/kernel.rbs +2 -2
  13. data/core/random.rbs +5 -220
  14. data/core/rational.rbs +3 -3
  15. data/core/rbs/unnamed/argf.rbs +965 -0
  16. data/core/rbs/unnamed/env_class.rbs +1325 -0
  17. data/core/rbs/unnamed/random.rbs +270 -0
  18. data/core/regexp.rbs +2 -3
  19. data/docs/CONTRIBUTING.md +2 -2
  20. data/ext/rbs_extension/lexer.c +1343 -1353
  21. data/ext/rbs_extension/lexer.re +2 -2
  22. data/ext/rbs_extension/rbs_extension.h +1 -1
  23. data/ext/rbs_extension/unescape.c +17 -10
  24. data/lib/rbs/ast/members.rb +6 -3
  25. data/lib/rbs/cli.rb +2 -0
  26. data/lib/rbs/factory.rb +2 -0
  27. data/lib/rbs/prototype/helpers.rb +1 -5
  28. data/lib/rbs/prototype/rb.rb +105 -56
  29. data/lib/rbs/prototype/rbi.rb +65 -30
  30. data/lib/rbs/prototype/runtime.rb +4 -3
  31. data/lib/rbs/test/setup_helper.rb +6 -1
  32. data/lib/rbs/version.rb +1 -1
  33. data/schema/members.json +4 -1
  34. data/sig/collection/config.rbs +3 -0
  35. data/sig/factory.rbs +5 -0
  36. data/sig/prototype/helpers.rbs +23 -0
  37. data/sig/prototype/rb.rbs +84 -0
  38. data/sig/prototype/rbi.rbs +73 -0
  39. data/sig/shims/abstract_syntax_tree.rbs +25 -0
  40. data/sig/shims/enumerable.rbs +5 -0
  41. data/sig/shims/pp.rbs +3 -0
  42. data/sig/shims/ripper.rbs +8 -0
  43. data/stdlib/cgi/0/manifest.yaml +2 -0
  44. data/stdlib/date/0/time.rbs +26 -0
  45. data/stdlib/etc/0/etc.rbs +745 -0
  46. data/stdlib/minitest/0/kernel.rbs +42 -0
  47. data/stdlib/minitest/0/manifest.yaml +2 -0
  48. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +49 -0
  49. data/stdlib/minitest/0/minitest/assertion.rbs +16 -0
  50. data/stdlib/minitest/0/minitest/assertions.rbs +545 -0
  51. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +16 -0
  52. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  53. data/stdlib/minitest/0/minitest/benchmark.rbs +258 -0
  54. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  55. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  56. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  57. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  58. data/stdlib/minitest/0/minitest/mock.rbs +60 -0
  59. data/stdlib/minitest/0/minitest/parallel/executor.rbs +42 -0
  60. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +6 -0
  61. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  62. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  63. data/stdlib/minitest/0/minitest/pride_io.rbs +54 -0
  64. data/stdlib/minitest/0/minitest/pride_lol.rbs +17 -0
  65. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  66. data/stdlib/minitest/0/minitest/reportable.rbs +51 -0
  67. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  68. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  69. data/stdlib/minitest/0/minitest/runnable.rbs +131 -0
  70. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  71. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  72. data/stdlib/minitest/0/minitest/spec/dsl.rbs +125 -0
  73. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  74. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +76 -0
  75. data/stdlib/minitest/0/minitest/summary_reporter.rbs +25 -0
  76. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  77. data/stdlib/minitest/0/minitest/test.rbs +76 -0
  78. data/stdlib/minitest/0/minitest/unexpected_error.rbs +10 -0
  79. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  80. data/stdlib/minitest/0/minitest/unit.rbs +5 -0
  81. data/stdlib/minitest/0/minitest.rbs +966 -0
  82. data/stdlib/rubygems/0/errors.rbs +113 -0
  83. metadata +54 -4
  84. data/lib/rbs/char_scanner.rb +0 -20
@@ -115,7 +115,7 @@ $:: Array[String]
115
115
  $;: Regexp | String | nil
116
116
 
117
117
  # The same as ARGF.
118
- $<: IO
118
+ $<: RBS::Unnamed::ARGFClass
119
119
 
120
120
  # This variable is no longer effective. Deprecated.
121
121
  $=: bool
data/core/hash.rbs CHANGED
@@ -978,7 +978,7 @@ class Hash[unchecked out K, unchecked out V] < Object
978
978
  # h.dig(:hello, :world) # => h
979
979
  # h.dig(:hello, :world, :foo, :bar, 2) # => :c
980
980
  #
981
- def dig: (*untyped) -> untyped
981
+ def dig: (K, *untyped) -> untyped
982
982
 
983
983
  # <!-- rdoc-file=hash.c -->
984
984
  # Hash#each is an alias for Hash#each_pair.
@@ -1543,8 +1543,8 @@ class Hash[unchecked out K, unchecked out V] < Object
1543
1543
  # h1 = e.each {|key, value| key.start_with?('b') }
1544
1544
  # h1 # => {:foo=>0}
1545
1545
  #
1546
- def reject: () -> ::Enumerator[[ K, V ], self]
1547
- | () { (K, V) -> boolish } -> self
1546
+ def reject: () -> ::Enumerator[[ K, V ], ::Hash[K, V]]
1547
+ | () { (K, V) -> boolish } -> ::Hash[K, V]
1548
1548
 
1549
1549
  # <!--
1550
1550
  # rdoc-file=hash.c
data/core/kernel.rbs CHANGED
@@ -871,8 +871,8 @@ module Kernel : BasicObject
871
871
  # raise ArgumentError, "No parameters", caller
872
872
  #
873
873
  def self?.fail: () -> bot
874
- | (String arg0) -> bot
875
- | (_Exception arg0, ?untyped arg1, ?::Array[String] arg2) -> bot
874
+ | (String message, ?cause: Exception?) -> bot
875
+ | (_Exception exception, ?untyped message, ?::Array[String] backtrace, ?cause: Exception?) -> bot
876
876
 
877
877
  # <!--
878
878
  # rdoc-file=eval.c
data/core/random.rbs CHANGED
@@ -20,9 +20,7 @@
20
20
  # of 2**19937-1. As this algorithm is *not* for cryptographical use, you must
21
21
  # use SecureRandom for security purpose, instead of this PRNG.
22
22
  #
23
- class Random < Object
24
- include Random::Formatter
25
-
23
+ class Random < RBS::Unnamed::Random_Base
26
24
  # <!--
27
25
  # rdoc-file=random.c
28
26
  # - prng1 == prng2 -> true or false
@@ -49,78 +47,6 @@ class Random < Object
49
47
  #
50
48
  def ==: (untyped arg0) -> bool
51
49
 
52
- # <!--
53
- # rdoc-file=random.c
54
- # - prng.bytes(size) -> string
55
- # -->
56
- # Returns a random binary string containing `size` bytes.
57
- #
58
- # random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO"
59
- # random_string.size # => 10
60
- #
61
- def bytes: (Integer size) -> String
62
-
63
- # <!--
64
- # rdoc-file=random.c
65
- # - Random.new(seed = Random.new_seed) -> prng
66
- # -->
67
- # Creates a new PRNG using `seed` to set the initial state. If `seed` is
68
- # omitted, the generator is initialized with Random.new_seed.
69
- #
70
- # See Random.srand for more information on the use of seed values.
71
- #
72
- def initialize: (?Integer seed) -> void
73
-
74
- # <!--
75
- # rdoc-file=random.c
76
- # - prng.rand -> float
77
- # - prng.rand(max) -> number
78
- # - prng.rand(range) -> number
79
- # -->
80
- # When `max` is an Integer, `rand` returns a random integer greater than or
81
- # equal to zero and less than `max`. Unlike Kernel.rand, when `max` is a
82
- # negative integer or zero, `rand` raises an ArgumentError.
83
- #
84
- # prng = Random.new
85
- # prng.rand(100) # => 42
86
- #
87
- # When `max` is a Float, `rand` returns a random floating point number between
88
- # 0.0 and `max`, including 0.0 and excluding `max`.
89
- #
90
- # prng.rand(1.5) # => 1.4600282860034115
91
- #
92
- # When `range` is a Range, `rand` returns a random number where
93
- # `range.member?(number) == true`.
94
- #
95
- # prng.rand(5..9) # => one of [5, 6, 7, 8, 9]
96
- # prng.rand(5...9) # => one of [5, 6, 7, 8]
97
- # prng.rand(5.0..9.0) # => between 5.0 and 9.0, including 9.0
98
- # prng.rand(5.0...9.0) # => between 5.0 and 9.0, excluding 9.0
99
- #
100
- # Both the beginning and ending values of the range must respond to subtract
101
- # (`-`) and add (`+`)methods, or rand will raise an ArgumentError.
102
- #
103
- def rand: () -> Float
104
- | (Integer | ::Range[Integer] max) -> Integer
105
- | (Float | ::Range[Float] max) -> Float
106
-
107
- # <!--
108
- # rdoc-file=random.c
109
- # - prng.seed -> integer
110
- # -->
111
- # Returns the seed value used to initialize the generator. This may be used to
112
- # initialize another generator with the same state at a later time, causing it
113
- # to produce the same sequence of numbers.
114
- #
115
- # prng1 = Random.new(1234)
116
- # prng1.seed #=> 1234
117
- # prng1.rand(100) #=> 47
118
- #
119
- # prng2 = Random.new(prng1.seed)
120
- # prng2.rand(100) #=> 47
121
- #
122
- def seed: () -> Integer
123
-
124
50
  # <!--
125
51
  # rdoc-file=random.c
126
52
  # - Random.new_seed -> integer
@@ -173,6 +99,9 @@ end
173
99
 
174
100
  Random::DEFAULT: Random
175
101
 
102
+ class Random::Base < RBS::Unnamed::Random_Base
103
+ end
104
+
176
105
  # <!-- rdoc-file=lib/random/formatter.rb -->
177
106
  # ## Random number formatter.
178
107
  #
@@ -220,149 +149,5 @@ Random::DEFAULT: Random
220
149
  # prng.rand(1..6) #=> 3
221
150
  #
222
151
  module Random::Formatter
223
- # <!--
224
- # rdoc-file=lib/random/formatter.rb
225
- # - base64(n=nil)
226
- # -->
227
- # Random::Formatter#base64 generates a random base64 string.
228
- #
229
- # The argument *n* specifies the length, in bytes, of the random number to be
230
- # generated. The length of the result string is about 4/3 of *n*.
231
- #
232
- # If *n* is not specified or is nil, 16 is assumed. It may be larger in the
233
- # future.
234
- #
235
- # The result may contain A-Z, a-z, 0-9, "+", "/" and "=".
236
- #
237
- # require 'random/formatter'
238
- #
239
- # prng.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
240
- # prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
241
- #
242
- # See RFC 3548 for the definition of base64.
243
- #
244
- def base64: (?Integer? n) -> String
245
-
246
- # <!--
247
- # rdoc-file=lib/random/formatter.rb
248
- # - hex(n=nil)
249
- # -->
250
- # Random::Formatter#hex generates a random hexadecimal string.
251
- #
252
- # The argument *n* specifies the length, in bytes, of the random number to be
253
- # generated. The length of the resulting hexadecimal string is twice of *n*.
254
- #
255
- # If *n* is not specified or is nil, 16 is assumed. It may be larger in the
256
- # future.
257
- #
258
- # The result may contain 0-9 and a-f.
259
- #
260
- # require 'random/formatter'
261
- #
262
- # prng.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
263
- # prng.hex #=> "91dc3bfb4de5b11d029d376634589b61"
264
- #
265
- def hex: (?Integer? n) -> String
266
-
267
- # <!-- rdoc-file=random.c -->
268
- # Generates formatted random number from raw random bytes. See Random#rand.
269
- #
270
- def rand: () -> Float
271
- | (?Float? n) -> Float
272
- | (?Integer? n) -> Integer
273
- | (?Numeric? n) -> Numeric
274
- | (?::Range[Float]? n) -> Float
275
- | (?::Range[Integer]? n) -> Integer
276
- | (?::Range[Numeric]? n) -> Numeric
277
-
278
- # <!--
279
- # rdoc-file=lib/random/formatter.rb
280
- # - random_bytes(n=nil)
281
- # -->
282
- # Random::Formatter#random_bytes generates a random binary string.
283
- #
284
- # The argument *n* specifies the length of the result string.
285
- #
286
- # If *n* is not specified or is nil, 16 is assumed. It may be larger in future.
287
- #
288
- # The result may contain any byte: "x00" - "xff".
289
- #
290
- # require 'random/formatter'
291
- #
292
- # prng.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
293
- # prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
294
- #
295
- def random_bytes: (?Integer? n) -> String
296
-
297
- # <!--
298
- # rdoc-file=random.c
299
- # - prng.random_number -> float
300
- # - prng.random_number(max) -> number
301
- # - prng.random_number(range) -> number
302
- # - prng.rand -> float
303
- # - prng.rand(max) -> number
304
- # - prng.rand(range) -> number
305
- # -->
306
- # Generates formatted random number from raw random bytes. See Random#rand.
307
- #
308
- def random_number: () -> Float
309
- | (?Float? n) -> Float
310
- | (?Integer? n) -> Integer
311
- | (?Numeric? n) -> Numeric
312
- | (?::Range[Float]? n) -> Float
313
- | (?::Range[Integer]? n) -> Integer
314
- | (?::Range[Numeric]? n) -> Numeric
315
-
316
- # <!--
317
- # rdoc-file=lib/random/formatter.rb
318
- # - urlsafe_base64(n=nil, padding=false)
319
- # -->
320
- # Random::Formatter#urlsafe_base64 generates a random URL-safe base64 string.
321
- #
322
- # The argument *n* specifies the length, in bytes, of the random number to be
323
- # generated. The length of the result string is about 4/3 of *n*.
324
- #
325
- # If *n* is not specified or is nil, 16 is assumed. It may be larger in the
326
- # future.
327
- #
328
- # The boolean argument *padding* specifies the padding. If it is false or nil,
329
- # padding is not generated. Otherwise padding is generated. By default, padding
330
- # is not generated because "=" may be used as a URL delimiter.
331
- #
332
- # The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if
333
- # *padding* is true.
334
- #
335
- # require 'random/formatter'
336
- #
337
- # prng.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
338
- # prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
339
- #
340
- # prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
341
- # prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
342
- #
343
- # See RFC 3548 for the definition of URL-safe base64.
344
- #
345
- def urlsafe_base64: (?Integer? n, ?boolish padding) -> String
346
-
347
- # <!--
348
- # rdoc-file=lib/random/formatter.rb
349
- # - uuid()
350
- # -->
351
- # Random::Formatter#uuid generates a random v4 UUID (Universally Unique
352
- # IDentifier).
353
- #
354
- # require 'random/formatter'
355
- #
356
- # prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
357
- # prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
358
- # prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
359
- #
360
- # The version 4 UUID is purely random (except the version). It doesn't contain
361
- # meaningful information such as MAC addresses, timestamps, etc.
362
- #
363
- # The result contains 122 random bits (15.25 random bytes).
364
- #
365
- # See RFC 4122 for details of UUID.
366
- #
367
- def uuid: () -> String
152
+ include RBS::Unnamed::Random_Formatter
368
153
  end
data/core/rational.rbs CHANGED
@@ -68,9 +68,9 @@ class Rational < Numeric
68
68
  # Rational(9, 8) * 4 #=> (9/2)
69
69
  # Rational(20, 9) * 9.8 #=> 21.77777777777778
70
70
  #
71
- def *: (Float) -> Float
72
- | (Complex) -> Complex
73
- | (Numeric) -> Numeric
71
+ def *: (Integer) -> Rational
72
+ | (Rational) -> Rational
73
+ | [T < Numeric](T) -> T
74
74
 
75
75
  # <!--
76
76
  # rdoc-file=rational.c