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
data/core/proc.rbs CHANGED
@@ -201,8 +201,8 @@
201
201
  # ["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"]
202
202
  # ["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"]
203
203
  #
204
- # Of the Ruby core classes, this method is implemented by Symbol, Method, and
205
- # Hash.
204
+ # Of the Ruby core classes, this method is implemented by `Symbol`, `Method`,
205
+ # and `Hash`.
206
206
  #
207
207
  # :to_s.to_proc.call(1) #=> "1"
208
208
  # [1, 2].map(&:to_s) #=> ["1", "2"]
@@ -285,7 +285,7 @@
285
285
  # [1, 2, 3].each { |x| p it }
286
286
  # # syntax error found (SyntaxError)
287
287
  # # [1, 2, 3].each { |x| p it }
288
- # # ^~ `it` is not allowed when an ordinary parameter is defined
288
+ # # ^~ 'it' is not allowed when an ordinary parameter is defined
289
289
  #
290
290
  # But if a local name (variable or method) is available, it would be used:
291
291
  #
@@ -302,7 +302,7 @@
302
302
  #
303
303
  # p = proc { it**2 }
304
304
  # l = lambda { it**2 }
305
- # p.parameters # => [[:opt, nil]]
305
+ # p.parameters # => [[:opt]]
306
306
  # p.arity # => 1
307
307
  # l.parameters # => [[:req]]
308
308
  # l.arity # => 1
@@ -332,7 +332,7 @@
332
332
  # Numbered parameters can't be mixed with `it` either:
333
333
  #
334
334
  # [10, 20, 30].map { _1 + it }
335
- # # SyntaxError: `it` is not allowed when a numbered parameter is already used
335
+ # # SyntaxError: 'it' is not allowed when a numbered parameter is already used
336
336
  #
337
337
  # To avoid conflicts, naming local variables or method arguments `_1`, `_2` and
338
338
  # so on, causes an error.
@@ -377,12 +377,11 @@ class Proc
377
377
  def self.new: () { (?) -> untyped } -> instance
378
378
 
379
379
  def clone: () -> self
380
- def dup: () -> self
381
380
 
382
381
  # <!-- rdoc-file=proc.c -->
383
- # Invokes the block, setting the block's parameters to the values in *params*
384
- # using something close to method calling semantics. Returns the value of the
385
- # last expression evaluated in the block.
382
+ # Invokes the block, setting the block's parameters to the arguments using
383
+ # something close to method calling semantics. Returns the value of the last
384
+ # expression evaluated in the block.
386
385
  #
387
386
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
388
387
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -409,9 +408,9 @@ class Proc
409
408
  alias === call
410
409
 
411
410
  # <!-- rdoc-file=proc.c -->
412
- # Invokes the block, setting the block's parameters to the values in *params*
413
- # using something close to method calling semantics. Returns the value of the
414
- # last expression evaluated in the block.
411
+ # Invokes the block, setting the block's parameters to the arguments using
412
+ # something close to method calling semantics. Returns the value of the last
413
+ # expression evaluated in the block.
415
414
  #
416
415
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
417
416
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -592,14 +591,13 @@ class Proc
592
591
 
593
592
  # <!--
594
593
  # rdoc-file=proc.c
595
- # - prc.call(params,...) -> obj
596
- # - prc[params,...] -> obj
597
- # - prc.(params,...) -> obj
598
- # - prc.yield(params,...) -> obj
594
+ # - call(...) -> obj
595
+ # - self[...] -> obj
596
+ # - yield(...) -> obj
599
597
  # -->
600
- # Invokes the block, setting the block's parameters to the values in *params*
601
- # using something close to method calling semantics. Returns the value of the
602
- # last expression evaluated in the block.
598
+ # Invokes the block, setting the block's parameters to the arguments using
599
+ # something close to method calling semantics. Returns the value of the last
600
+ # expression evaluated in the block.
603
601
  #
604
602
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
605
603
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -626,9 +624,9 @@ class Proc
626
624
  def call: (?) -> untyped
627
625
 
628
626
  # <!-- rdoc-file=proc.c -->
629
- # Invokes the block, setting the block's parameters to the values in *params*
630
- # using something close to method calling semantics. Returns the value of the
631
- # last expression evaluated in the block.
627
+ # Invokes the block, setting the block's parameters to the arguments using
628
+ # something close to method calling semantics. Returns the value of the last
629
+ # expression evaluated in the block.
632
630
  #
633
631
  # a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
634
632
  # a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
@@ -835,10 +833,17 @@ class Proc
835
833
 
836
834
  # <!--
837
835
  # rdoc-file=proc.c
838
- # - prc.source_location -> [String, Integer]
836
+ # - prc.source_location -> [String, Integer, Integer, Integer, Integer]
839
837
  # -->
840
- # Returns the Ruby source filename and line number containing this proc or `nil`
841
- # if this proc was not defined in Ruby (i.e. native).
838
+ # Returns the location where the Proc was defined. The returned Array contains:
839
+ # (1) the Ruby source filename
840
+ # (2) the line number where the definition starts
841
+ # (3) the column number where the definition starts
842
+ # (4) the line number where the definition ends
843
+ # (5) the column number where the definitions ends
844
+ #
845
+ # This method will return `nil` if the Proc was not defined in Ruby (i.e.
846
+ # native).
842
847
  #
843
848
  def source_location: () -> [String, Integer]?
844
849
 
data/core/process.rbs CHANGED
@@ -590,7 +590,7 @@ module Process
590
590
  # * `:microsecond`: Number of microseconds as an integer.
591
591
  # * `:millisecond`: Number of milliseconds as an integer.
592
592
  # * `:nanosecond`: Number of nanoseconds as an integer.
593
- # * `::second`: Number of seconds as an integer.
593
+ # * `:second`: Number of seconds as an integer.
594
594
  #
595
595
  # Examples:
596
596
  #
@@ -1861,6 +1861,7 @@ class Process::Status < Object
1861
1861
  #
1862
1862
  # ArgumentError is raised if `mask` is negative.
1863
1863
  #
1864
+ %a{deprecated}
1864
1865
  def &: (Integer num) -> Integer
1865
1866
 
1866
1867
  # <!--
@@ -1893,6 +1894,7 @@ class Process::Status < Object
1893
1894
  #
1894
1895
  # ArgumentError is raised if `places` is negative.
1895
1896
  #
1897
+ %a{deprecated}
1896
1898
  def >>: (Integer num) -> Integer
1897
1899
 
1898
1900
  # <!--
@@ -2023,7 +2025,7 @@ end
2023
2025
  # <!-- rdoc-file=process.c -->
2024
2026
  # The Process::Sys module contains UID and GID functions which provide direct
2025
2027
  # bindings to the system calls of the same names instead of the more-portable
2026
- # versions of the same functionality found in the Process, Process::UID, and
2028
+ # versions of the same functionality found in the `Process`, Process::UID, and
2027
2029
  # Process::GID modules.
2028
2030
  #
2029
2031
  module Process::Sys