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/range.rbs CHANGED
@@ -86,14 +86,14 @@
86
86
  # end
87
87
  # a # => [2, 4, 6, 8, 10]
88
88
  #
89
- # A range can be both beginless and endless. For literal beginless, endless
89
+ # A range can be both beginless and endless. For literal beginless, endless
90
90
  # ranges, at least the beginning or end of the range must be given as an
91
91
  # explicit nil value. It is recommended to use an explicit nil beginning and
92
- # implicit nil end, since that is what Ruby uses for Range#inspect:
92
+ # end, since that is what Ruby uses for Range#inspect:
93
93
  #
94
- # (nil..) # => (nil..)
95
- # (..nil) # => (nil..)
96
- # (nil..nil) # => (nil..)
94
+ # (nil..) # => (nil..nil)
95
+ # (..nil) # => (nil..nil)
96
+ # (nil..nil) # => (nil..nil)
97
97
  #
98
98
  # ## Ranges and Other Classes
99
99
  #
@@ -351,7 +351,7 @@ class Range[out Elem] < Object
351
351
  # -->
352
352
  # Returns an element from `self` selected by a binary search.
353
353
  #
354
- # See [Binary Searching](rdoc-ref:bsearch.rdoc).
354
+ # See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
355
355
  #
356
356
  def bsearch: () -> ::Enumerator[Elem, Elem?]
357
357
  | () { (Elem) -> (true | false) } -> Elem?
@@ -936,8 +936,7 @@ class Range[out Elem] < Object
936
936
  #
937
937
  # Related: Range#count.
938
938
  #
939
- def size: () -> Integer?
940
- | () -> Float?
939
+ def size: () -> (Integer | Float | nil)
941
940
 
942
941
  # <!--
943
942
  # rdoc-file=range.c
data/core/rational.rbs CHANGED
@@ -53,15 +53,16 @@ class Rational < Numeric
53
53
 
54
54
  # <!--
55
55
  # rdoc-file=rational.c
56
- # - rat * numeric -> numeric
56
+ # - self * other -> numeric
57
57
  # -->
58
- # Performs multiplication.
58
+ # Returns the numeric product of `self` and `other`:
59
59
  #
60
- # Rational(2, 3) * Rational(2, 3) #=> (4/9)
61
- # Rational(900) * Rational(1) #=> (900/1)
62
- # Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
63
- # Rational(9, 8) * 4 #=> (9/2)
64
- # Rational(20, 9) * 9.8 #=> 21.77777777777778
60
+ # Rational(9, 8) * 4 #=> (9/2)
61
+ # Rational(20, 9) * 9.8 #=> 21.77777777777778
62
+ # Rational(9, 8) * Complex(1, 2) # => ((9/8)+(9/4)*i)
63
+ # Rational(2, 3) * Rational(2, 3) #=> (4/9)
64
+ # Rational(900) * Rational(1) #=> (900/1)
65
+ # Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
65
66
  #
66
67
  def *: (Integer) -> Rational
67
68
  | (Rational) -> Rational
@@ -69,9 +70,9 @@ class Rational < Numeric
69
70
 
70
71
  # <!--
71
72
  # rdoc-file=rational.c
72
- # - rat ** numeric -> numeric
73
+ # - self ** exponent -> numeric
73
74
  # -->
74
- # Performs exponentiation.
75
+ # Returns `self` raised to the power `exponent`:
75
76
  #
76
77
  # Rational(2) ** Rational(3) #=> (8/1)
77
78
  # Rational(10) ** -2 #=> (1/100)
@@ -85,15 +86,25 @@ class Rational < Numeric
85
86
 
86
87
  # <!--
87
88
  # rdoc-file=rational.c
88
- # - rat + numeric -> numeric
89
+ # - self + other -> numeric
89
90
  # -->
90
- # Performs addition.
91
+ # Returns the sum of `self` and `other`:
91
92
  #
92
- # Rational(2, 3) + Rational(2, 3) #=> (4/3)
93
- # Rational(900) + Rational(1) #=> (901/1)
94
- # Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
95
- # Rational(9, 8) + 4 #=> (41/8)
96
- # Rational(20, 9) + 9.8 #=> 12.022222222222222
93
+ # Rational(2, 3) + 0 # => (2/3)
94
+ # Rational(2, 3) + 1 # => (5/3)
95
+ # Rational(2, 3) + -1 # => (-1/3)
96
+ #
97
+ # Rational(2, 3) + Complex(1, 0) # => ((5/3)+0i)
98
+ #
99
+ # Rational(2, 3) + Rational(1, 1) # => (5/3)
100
+ # Rational(2, 3) + Rational(3, 2) # => (13/6)
101
+ # Rational(2, 3) + Rational(3.0, 2.0) # => (13/6)
102
+ # Rational(2, 3) + Rational(3.1, 2.1) # => (30399297484750849/14186338826217063)
103
+ #
104
+ # For a computation involving Floats, the result may be inexact (see Float#+):
105
+ #
106
+ # Rational(2, 3) + 1.0 # => 1.6666666666666665
107
+ # Rational(2, 3) + Complex(1.0, 0.0) # => (1.6666666666666665+0.0i)
97
108
  #
98
109
  def +: (Float) -> Float
99
110
  | (Complex) -> Complex
@@ -103,9 +114,9 @@ class Rational < Numeric
103
114
 
104
115
  # <!--
105
116
  # rdoc-file=rational.c
106
- # - rat - numeric -> numeric
117
+ # - self - other -> numeric
107
118
  # -->
108
- # Performs subtraction.
119
+ # Returns the difference of `self` and `other`:
109
120
  #
110
121
  # Rational(2, 3) - Rational(2, 3) #=> (0/1)
111
122
  # Rational(900) - Rational(1) #=> (899/1)
@@ -119,18 +130,20 @@ class Rational < Numeric
119
130
 
120
131
  # <!--
121
132
  # rdoc-file=rational.c
122
- # - -rat -> rational
133
+ # - -self -> rational
123
134
  # -->
124
- # Negates `rat`.
135
+ # Returns `self`, negated:
136
+ #
137
+ # -(1/3r) # => (-1/3)
138
+ # -(-1/3r) # => (1/3)
125
139
  #
126
140
  def -@: () -> Rational
127
141
 
128
142
  # <!--
129
143
  # rdoc-file=rational.c
130
- # - rat / numeric -> numeric
131
- # - rat.quo(numeric) -> numeric
144
+ # - self / other -> numeric
132
145
  # -->
133
- # Performs division.
146
+ # Returns the quotient of `self` and `other`:
134
147
  #
135
148
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
136
149
  # Rational(900) / Rational(1) #=> (900/1)
@@ -364,7 +377,7 @@ class Rational < Numeric
364
377
  def positive?: () -> bool
365
378
 
366
379
  # <!-- rdoc-file=rational.c -->
367
- # Performs division.
380
+ # Returns the quotient of `self` and `other`:
368
381
  #
369
382
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
370
383
  # Rational(900) / Rational(1) #=> (900/1)
@@ -93,7 +93,7 @@ module RBS
93
93
  # * File `t.rb`:
94
94
  #
95
95
  # p "ARGV: #{ARGV}"
96
- # p "Line: #{ARGF.read}" # Read everything from all specified streams.
96
+ # p "Read: #{ARGF.read}" # Read everything from all specified streams.
97
97
  #
98
98
  # * Command and output:
99
99
  #
@@ -836,7 +836,7 @@ module RBS
836
836
  # Formats and writes `objects` to the stream.
837
837
  #
838
838
  # For details on `format_string`, see [Format
839
- # Specifications](rdoc-ref:format_specifications.rdoc).
839
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
840
840
  #
841
841
  %a{annotate:rdoc:copy:ARGF#printf}
842
842
  def printf: (String format_string, *untyped args) -> nil
@@ -140,7 +140,7 @@ module RBS
140
140
  #
141
141
  # * ::assoc: Returns a 2-element array containing the name and value of the
142
142
  # named environment variable if it exists:
143
- # * ::clone: Returns `ENV` (and issues a warning).
143
+ # * ::clone: Raises an exception.
144
144
  # * ::except: Returns a hash of all name/value pairs except those given.
145
145
  # * ::fetch: Returns the value for the given name.
146
146
  # * ::inspect: Returns the contents of `ENV` as a string.
@@ -31,9 +31,11 @@ module RBS
31
31
  # prng.rand(100) # => 42
32
32
  #
33
33
  # When `max` is a Float, `rand` returns a random floating point number between
34
- # 0.0 and `max`, including 0.0 and excluding `max`.
34
+ # 0.0 and `max`, including 0.0 and excluding `max`. Note that it behaves
35
+ # differently from Kernel.rand.
35
36
  #
36
- # prng.rand(1.5) # => 1.4600282860034115
37
+ # prng.rand(1.5) # => 1.4600282860034115
38
+ # rand(1.5) # => 0
37
39
  #
38
40
  # When `range` is a Range, `rand` returns a random number where
39
41
  # `range.member?(number) == true`.
data/core/regexp.rbs CHANGED
@@ -39,7 +39,7 @@
39
39
  # most such methods accept an argument that may be either a string or the
40
40
  # (much more powerful) regexp.
41
41
  #
42
- # See [Regexp Methods](rdoc-ref:regexp/methods.rdoc).
42
+ # See [Regexp Methods](rdoc-ref:language/regexp/methods.rdoc).
43
43
  #
44
44
  # ## Regexp Objects
45
45
  #
@@ -126,6 +126,9 @@
126
126
  # `nil`. Note that `$0` is quite different; it returns the name of the
127
127
  # currently executing program.
128
128
  #
129
+ # These variables, except for `$~`, are shorthands for methods of `$~`. See
130
+ # MatchData@Global+variables+equivalence.
131
+ #
129
132
  # Examples:
130
133
  #
131
134
  # # Matched string, but no matched groups.
@@ -435,6 +438,9 @@
435
438
  # /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favors the <b>bold</b>.")
436
439
  # # => #<MatchData "bold">
437
440
  #
441
+ # The pattern in lookbehind must be fixed-width. But top-level alternatives can
442
+ # be of various lengths. ex. (?<=a|bc) is OK. (?<=aaa(?:b|cd)) is not allowed.
443
+ #
438
444
  # #### Match-Reset Anchor
439
445
  #
440
446
  # * `\K`: Match reset: the matched content preceding `\K` in the regexp is
@@ -495,7 +501,7 @@
495
501
  # /\w*/.match('x')
496
502
  # # => #<MatchData "x">
497
503
  # /\w*/.match('xyz')
498
- # # => #<MatchData "yz">
504
+ # # => #<MatchData "xyz">
499
505
  #
500
506
  # * `+` - Matches one or more times:
501
507
  #
@@ -708,7 +714,7 @@
708
714
  #
709
715
  # 1. The leading subexpression `"` in the pattern matches the first character
710
716
  # `"` in the target string.
711
- # 2. The next subexpression `.*` matches the next substring `Quote“` (including
717
+ # 2. The next subexpression `.*` matches the next substring `Quote"` (including
712
718
  # the trailing double-quote).
713
719
  # 3. Now there is nothing left in the target string to match the trailing
714
720
  # subexpression `"` in the pattern; this would cause the overall match to
@@ -815,8 +821,8 @@
815
821
  # /\P{Alpha}/.match('1') # => #<MatchData "1">
816
822
  # /\P{Alpha}/.match('a') # => nil
817
823
  #
818
- # See [Unicode Properties](rdoc-ref:regexp/unicode_properties.rdoc) for regexps
819
- # based on the numerous properties.
824
+ # See [Unicode Properties](rdoc-ref:language/regexp/unicode_properties.rdoc) for
825
+ # regexps based on the numerous properties.
820
826
  #
821
827
  # Some commonly-used properties correspond to POSIX bracket expressions:
822
828
  #
@@ -1248,7 +1254,7 @@
1248
1254
  #
1249
1255
  # Regexp matching can apply an optimization to prevent ReDoS attacks. When the
1250
1256
  # optimization is applied, matching time increases linearly (not polynomially or
1251
- # exponentially) in relation to the input size, and a ReDoS attach is not
1257
+ # exponentially) in relation to the input size, and a ReDoS attack is not
1252
1258
  # possible.
1253
1259
  #
1254
1260
  # This optimization is applied if the pattern meets these criteria:
@@ -1272,21 +1278,14 @@
1272
1278
  #
1273
1279
  # ## References
1274
1280
  #
1275
- # Read (online PDF books):
1281
+ # Read:
1276
1282
  #
1277
- # * [Mastering Regular
1278
- # Expressions](https://ia902508.us.archive.org/10/items/allitebooks-02/Maste
1279
- # ring%20Regular%20Expressions%2C%203rd%20Edition.pdf) by Jeffrey E.F.
1280
- # Friedl.
1281
- # * [Regular Expressions
1282
- # Cookbook](https://doc.lagout.org/programmation/Regular%20Expressions/Regul
1283
- # ar%20Expressions%20Cookbook_%20Detailed%20Solutions%20in%20Eight%20Program
1284
- # ming%20Languages%20%282nd%20ed.%29%20%5BGoyvaerts%20%26%20Levithan%202012-
1285
- # 09-06%5D.pdf) by Jan Goyvaerts & Steven Levithan.
1283
+ # * *Mastering Regular Expressions* by Jeffrey E.F. Friedl.
1284
+ # * *Regular Expressions Cookbook* by Jan Goyvaerts & Steven Levithan.
1286
1285
  #
1287
- # Explore, test (interactive online editor):
1286
+ # Explore, test:
1288
1287
  #
1289
- # * [Rubular](https://rubular.com/).
1288
+ # * [Rubular](https://rubular.com/): interactive online editor.
1290
1289
  #
1291
1290
  class Regexp
1292
1291
  # Represents an object's ability to be converted to a `Regexp`.
@@ -1297,6 +1296,9 @@ class Regexp
1297
1296
  def to_regexp: () -> Regexp
1298
1297
  end
1299
1298
 
1299
+ # <!-- rdoc-file=re.c -->
1300
+ # Raised when regexp matching timed out.
1301
+ #
1300
1302
  class TimeoutError < RegexpError
1301
1303
  end
1302
1304
 
@@ -1658,9 +1660,12 @@ class Regexp
1658
1660
 
1659
1661
  # <!--
1660
1662
  # rdoc-file=re.c
1661
- # - obj.encoding -> encoding
1663
+ # - encoding -> encoding
1662
1664
  # -->
1663
- # Returns the Encoding object that represents the encoding of obj.
1665
+ # Returns an Encoding object that represents the encoding of `self`; see
1666
+ # [Encodings](rdoc-ref:encodings.rdoc).
1667
+ #
1668
+ # Related: see [Querying](rdoc-ref:String@Querying).
1664
1669
  #
1665
1670
  def encoding: () -> Encoding
1666
1671
 
data/core/ruby.rbs ADDED
@@ -0,0 +1,53 @@
1
+ # <!-- rdoc-file=version.c -->
2
+ # The [Ruby](rdoc-ref:Ruby) module that contains portable information among
3
+ # implementations.
4
+ #
5
+ # The constants defined here are aliased in the toplevel with `RUBY_` prefix.
6
+ #
7
+ module Ruby
8
+ # <!-- rdoc-file=version.c -->
9
+ # The copyright string for ruby
10
+ #
11
+ COPYRIGHT: ::String
12
+
13
+ # <!-- rdoc-file=version.c -->
14
+ # The full ruby version string, like `ruby -v` prints
15
+ #
16
+ DESCRIPTION: ::String
17
+
18
+ # <!-- rdoc-file=version.c -->
19
+ # The engine or interpreter this ruby uses.
20
+ #
21
+ ENGINE: ::String
22
+
23
+ # <!-- rdoc-file=version.c -->
24
+ # The version of the engine or interpreter this ruby uses.
25
+ #
26
+ ENGINE_VERSION: ::String
27
+
28
+ # <!-- rdoc-file=version.c -->
29
+ # The patchlevel for this ruby. If this is a development build of ruby the
30
+ # patchlevel will be -1
31
+ #
32
+ PATCHLEVEL: ::Integer
33
+
34
+ # <!-- rdoc-file=version.c -->
35
+ # The platform for this ruby
36
+ #
37
+ PLATFORM: ::String
38
+
39
+ # <!-- rdoc-file=version.c -->
40
+ # The date this ruby was released
41
+ #
42
+ RELEASE_DATE: ::String
43
+
44
+ # <!-- rdoc-file=version.c -->
45
+ # The GIT commit hash for this ruby.
46
+ #
47
+ REVISION: ::String
48
+
49
+ # <!-- rdoc-file=version.c -->
50
+ # The running version of ruby
51
+ #
52
+ VERSION: ::String
53
+ end
data/core/ruby_vm.rbs CHANGED
@@ -443,7 +443,7 @@ module RubyVM::AbstractSyntaxTree
443
443
  #
444
444
  # See ::parse for explanation of keyword argument meaning and usage.
445
445
  #
446
- def self.parse_file: (String | ::_ToPath string, ?keep_script_lines: bool, ?error_tolerant: bool, ?keep_tokens: bool) -> Node
446
+ def self.parse_file: (path string, ?keep_script_lines: bool, ?error_tolerant: bool, ?keep_tokens: bool) -> Node
447
447
 
448
448
  # <!--
449
449
  # rdoc-file=ast.rb
@@ -683,11 +683,13 @@ module RubyVM::YJIT
683
683
 
684
684
  # <!--
685
685
  # rdoc-file=yjit.rb
686
- # - enable(stats: false, log: false)
686
+ # - enable(stats: false, log: false, mem_size: nil, call_threshold: nil)
687
687
  # -->
688
688
  # Enable YJIT compilation. `stats` option decides whether to enable YJIT stats
689
- # or not. `compilation_log` decides
690
- # whether to enable YJIT compilation logging or not.
689
+ # or not. `log` decides
690
+ # whether to enable YJIT compilation logging or not. Optional `mem_size` and
691
+ # `call_threshold` can be
692
+ # provided to override default configuration.
691
693
  # * `stats`:
692
694
  # * `false`: Don't enable stats.
693
695
  # * `true`: Enable stats. Print stats at exit.
@@ -17,7 +17,7 @@
17
17
  # Further RubyGems documentation can be found at:
18
18
  #
19
19
  # * [RubyGems Guides](https://guides.rubygems.org)
20
- # * [RubyGems API](https://www.rubydoc.info/github/rubygems/rubygems) (also
20
+ # * [RubyGems API](https://www.rubydoc.info/github/ruby/rubygems) (also
21
21
  # available from `gem server`)
22
22
  #
23
23
  # ## RubyGems Plugins
@@ -48,7 +48,7 @@
48
48
  # ## Bugs
49
49
  #
50
50
  # You can submit bugs to the [RubyGems bug
51
- # tracker](https://github.com/rubygems/rubygems/issues) on GitHub
51
+ # tracker](https://github.com/ruby/rubygems/issues) on GitHub
52
52
  #
53
53
  # ## Credits
54
54
  #
@@ -83,80 +83,13 @@
83
83
  #
84
84
  # ## License
85
85
  #
86
- # See
87
- # [LICENSE.txt](https://github.com/rubygems/rubygems/blob/master/LICENSE.txt)
86
+ # See [LICENSE.txt](https://github.com/ruby/rubygems/blob/master/LICENSE.txt)
88
87
  # for permissions.
89
88
  #
90
89
  # Thanks!
91
90
  #
92
91
  # -The RubyGems Team
93
92
  #
94
- # <!-- rdoc-file=lib/rubygems/deprecate.rb -->
95
- # Provides 3 methods for declaring when something is going away.
96
- #
97
- # +deprecate(name, repl, year, month)+:
98
- # Indicate something may be removed on/after a certain date.
99
- #
100
- # +rubygems_deprecate(name, replacement=:none)+:
101
- # Indicate something will be removed in the next major RubyGems version,
102
- # and (optionally) a replacement for it.
103
- #
104
- # `rubygems_deprecate_command`:
105
- # Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
106
- # removed in the next RubyGems version.
107
- #
108
- # Also provides `skip_during` for temporarily turning off deprecation warnings.
109
- # This is intended to be used in the test suite, so deprecation warnings don't
110
- # cause test failures if you need to make sure stderr is otherwise empty.
111
- #
112
- # Example usage of `deprecate` and `rubygems_deprecate`:
113
- #
114
- # class Legacy
115
- # def self.some_class_method
116
- # # ...
117
- # end
118
- #
119
- # def some_instance_method
120
- # # ...
121
- # end
122
- #
123
- # def some_old_method
124
- # # ...
125
- # end
126
- #
127
- # extend Gem::Deprecate
128
- # deprecate :some_instance_method, "X.z", 2011, 4
129
- # rubygems_deprecate :some_old_method, "Modern#some_new_method"
130
- #
131
- # class << self
132
- # extend Gem::Deprecate
133
- # deprecate :some_class_method, :none, 2011, 4
134
- # end
135
- # end
136
- #
137
- # Example usage of `rubygems_deprecate_command`:
138
- #
139
- # class Gem::Commands::QueryCommand < Gem::Command
140
- # extend Gem::Deprecate
141
- # rubygems_deprecate_command
142
- #
143
- # # ...
144
- # end
145
- #
146
- # Example usage of `skip_during`:
147
- #
148
- # class TestSomething < Gem::Testcase
149
- # def test_some_thing_with_deprecations
150
- # Gem::Deprecate.skip_during do
151
- # actual_stdout, actual_stderr = capture_output do
152
- # Gem.something_deprecated
153
- # end
154
- # assert_empty actual_stdout
155
- # assert_equal(expected, actual_stderr)
156
- # end
157
- # end
158
- # end
159
- #
160
93
  module Gem
161
94
  # <!-- rdoc-file=lib/rubygems/errors.rb -->
162
95
  # Raised when RubyGems is unable to load or activate a gem. Contains the name
@@ -17,7 +17,7 @@
17
17
  # Further RubyGems documentation can be found at:
18
18
  #
19
19
  # * [RubyGems Guides](https://guides.rubygems.org)
20
- # * [RubyGems API](https://www.rubydoc.info/github/rubygems/rubygems) (also
20
+ # * [RubyGems API](https://www.rubydoc.info/github/ruby/rubygems) (also
21
21
  # available from `gem server`)
22
22
  #
23
23
  # ## RubyGems Plugins
@@ -48,7 +48,7 @@
48
48
  # ## Bugs
49
49
  #
50
50
  # You can submit bugs to the [RubyGems bug
51
- # tracker](https://github.com/rubygems/rubygems/issues) on GitHub
51
+ # tracker](https://github.com/ruby/rubygems/issues) on GitHub
52
52
  #
53
53
  # ## Credits
54
54
  #
@@ -83,80 +83,13 @@
83
83
  #
84
84
  # ## License
85
85
  #
86
- # See
87
- # [LICENSE.txt](https://github.com/rubygems/rubygems/blob/master/LICENSE.txt)
86
+ # See [LICENSE.txt](https://github.com/ruby/rubygems/blob/master/LICENSE.txt)
88
87
  # for permissions.
89
88
  #
90
89
  # Thanks!
91
90
  #
92
91
  # -The RubyGems Team
93
92
  #
94
- # <!-- rdoc-file=lib/rubygems/deprecate.rb -->
95
- # Provides 3 methods for declaring when something is going away.
96
- #
97
- # +deprecate(name, repl, year, month)+:
98
- # Indicate something may be removed on/after a certain date.
99
- #
100
- # +rubygems_deprecate(name, replacement=:none)+:
101
- # Indicate something will be removed in the next major RubyGems version,
102
- # and (optionally) a replacement for it.
103
- #
104
- # `rubygems_deprecate_command`:
105
- # Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
106
- # removed in the next RubyGems version.
107
- #
108
- # Also provides `skip_during` for temporarily turning off deprecation warnings.
109
- # This is intended to be used in the test suite, so deprecation warnings don't
110
- # cause test failures if you need to make sure stderr is otherwise empty.
111
- #
112
- # Example usage of `deprecate` and `rubygems_deprecate`:
113
- #
114
- # class Legacy
115
- # def self.some_class_method
116
- # # ...
117
- # end
118
- #
119
- # def some_instance_method
120
- # # ...
121
- # end
122
- #
123
- # def some_old_method
124
- # # ...
125
- # end
126
- #
127
- # extend Gem::Deprecate
128
- # deprecate :some_instance_method, "X.z", 2011, 4
129
- # rubygems_deprecate :some_old_method, "Modern#some_new_method"
130
- #
131
- # class << self
132
- # extend Gem::Deprecate
133
- # deprecate :some_class_method, :none, 2011, 4
134
- # end
135
- # end
136
- #
137
- # Example usage of `rubygems_deprecate_command`:
138
- #
139
- # class Gem::Commands::QueryCommand < Gem::Command
140
- # extend Gem::Deprecate
141
- # rubygems_deprecate_command
142
- #
143
- # # ...
144
- # end
145
- #
146
- # Example usage of `skip_during`:
147
- #
148
- # class TestSomething < Gem::Testcase
149
- # def test_some_thing_with_deprecations
150
- # Gem::Deprecate.skip_during do
151
- # actual_stdout, actual_stderr = capture_output do
152
- # Gem.something_deprecated
153
- # end
154
- # assert_empty actual_stdout
155
- # assert_equal(expected, actual_stderr)
156
- # end
157
- # end
158
- # end
159
- #
160
93
  module Gem
161
94
  interface _HashLike[K, V]
162
95
  def each_pair: () { ([ K, V ]) -> untyped } -> self
@@ -204,7 +137,7 @@ module Gem
204
137
 
205
138
  VERSION: String
206
139
 
207
- # <!-- rdoc-file=lib/rubygems.rb -->
140
+ # <!-- rdoc-file=lib/rubygems/win_platform.rb -->
208
141
  # An Array of Regexps that match windows Ruby platforms.
209
142
  #
210
143
  WIN_PATTERNS: Array[Regexp]
@@ -251,7 +184,7 @@ module Gem
251
184
 
252
185
  # <!--
253
186
  # rdoc-file=lib/rubygems.rb
254
- # - bindir(install_dir=Gem.dir)
187
+ # - bindir(install_dir = Gem.dir)
255
188
  # -->
256
189
  # The path where gem executables are to be installed.
257
190
  #
@@ -509,7 +442,7 @@ module Gem
509
442
 
510
443
  # <!--
511
444
  # rdoc-file=lib/rubygems.rb
512
- # - find_files(glob, check_load_path=true)
445
+ # - find_files(glob, check_load_path = true)
513
446
  # -->
514
447
  # Returns a list of paths matching `glob` that can be used by a gem to pick up
515
448
  # features from other gems. For example:
@@ -526,7 +459,7 @@ module Gem
526
459
 
527
460
  # <!--
528
461
  # rdoc-file=lib/rubygems.rb
529
- # - find_latest_files(glob, check_load_path=true)
462
+ # - find_latest_files(glob, check_load_path = true)
530
463
  # -->
531
464
  # Returns a list of paths matching `glob` from the latest gems that can be used
532
465
  # by a gem to pick up features from other gems. For example:
@@ -551,7 +484,7 @@ module Gem
551
484
 
552
485
  # <!--
553
486
  # rdoc-file=lib/rubygems.rb
554
- # - finish_resolve(request_set=Gem::RequestSet.new)
487
+ # - finish_resolve(request_set = Gem::RequestSet.new)
555
488
  # -->
556
489
  #
557
490
  def self.finish_resolve: (?RequestSet request_set) -> void
@@ -804,7 +737,7 @@ module Gem
804
737
 
805
738
  # <!--
806
739
  # rdoc-file=lib/rubygems.rb
807
- # - plugindir(install_dir=Gem.dir)
740
+ # - plugindir(install_dir = Gem.dir)
808
741
  # -->
809
742
  # The path were rubygems plugins are to be installed.
810
743
  #
@@ -1009,8 +942,7 @@ module Gem
1009
942
  # - source_date_epoch_string()
1010
943
  # -->
1011
944
  # If the SOURCE_DATE_EPOCH environment variable is set, returns it's value.
1012
- # Otherwise, returns the time that `Gem.source_date_epoch_string` was first
1013
- # called in the same format as SOURCE_DATE_EPOCH.
945
+ # Otherwise, returns DEFAULT_SOURCE_DATE_EPOCH as a string.
1014
946
  #
1015
947
  # NOTE(@duckinator): The implementation is a tad weird because we want to:
1016
948
  # 1. Make builds reproducible by default, by having this function always
@@ -1154,7 +1086,7 @@ module Gem
1154
1086
  def self.user_home: () -> String
1155
1087
 
1156
1088
  # <!--
1157
- # rdoc-file=lib/rubygems.rb
1089
+ # rdoc-file=lib/rubygems/win_platform.rb
1158
1090
  # - win_platform?()
1159
1091
  # -->
1160
1092
  # Is this a windows platform?
@@ -180,7 +180,6 @@ module Gem
180
180
  #
181
181
  # ver1 = Version.create('1.3.17') # -> (Version object)
182
182
  # ver2 = Version.create(ver1) # -> (ver1)
183
- # ver3 = Version.create(nil) # -> nil
184
183
  #
185
184
  def self.create: (_ToS | Version input) -> instance
186
185
  | (nil input) -> nil
@@ -199,8 +198,8 @@ module Gem
199
198
  # - <=>(other)
200
199
  # -->
201
200
  # Compares this version with `other` returning -1, 0, or 1 if the other version
202
- # is larger, the same, or smaller than this one. Attempts to compare to
203
- # something that's not a `Gem::Version` or a valid version String return `nil`.
201
+ # is larger, the same, or smaller than this one. `other` must be an instance of
202
+ # Gem::Version, comparing with other types may raise an exception.
204
203
  #
205
204
  def <=>: (untyped other) -> Integer?
206
205