rbs 4.1.0.pre.1 → 4.1.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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +37 -0
  3. data/.github/workflows/bundle-update.yml +1 -1
  4. data/.github/workflows/c-check.yml +14 -6
  5. data/.github/workflows/comments.yml +2 -2
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/jruby.yml +79 -0
  8. data/.github/workflows/milestone.yml +13 -2
  9. data/.github/workflows/ruby.yml +16 -4
  10. data/.github/workflows/rust.yml +13 -8
  11. data/.github/workflows/truffleruby.yml +54 -0
  12. data/.github/workflows/typecheck.yml +5 -2
  13. data/.github/workflows/wasm.yml +55 -0
  14. data/.github/workflows/windows.yml +8 -2
  15. data/.gitignore +8 -0
  16. data/CHANGELOG.md +88 -0
  17. data/Dockerfile.jruby +53 -0
  18. data/README.md +3 -3
  19. data/Rakefile +103 -1
  20. data/Steepfile +9 -0
  21. data/core/array.rbs +243 -180
  22. data/core/builtin.rbs +6 -6
  23. data/core/enumerable.rbs +109 -109
  24. data/core/enumerator/product.rbs +5 -5
  25. data/core/enumerator.rbs +28 -28
  26. data/core/file.rbs +24 -1018
  27. data/core/file_constants.rbs +463 -0
  28. data/core/file_stat.rbs +534 -0
  29. data/core/float.rbs +0 -24
  30. data/core/hash.rbs +117 -101
  31. data/core/integer.rbs +21 -58
  32. data/core/io.rbs +25 -7
  33. data/core/match_data.rbs +1 -1
  34. data/core/module.rbs +88 -74
  35. data/core/numeric.rbs +3 -0
  36. data/core/object_space/weak_key_map.rbs +7 -7
  37. data/core/pathname.rbs +0 -10
  38. data/core/ractor.rbs +0 -10
  39. data/core/range.rbs +23 -23
  40. data/core/rbs/ops.rbs +154 -0
  41. data/core/rbs/unnamed/argf.rbs +3 -3
  42. data/core/rubygems/errors.rbs +4 -1
  43. data/core/rubygems/requirement.rbs +0 -10
  44. data/core/rubygems/rubygems.rbs +4 -1
  45. data/core/rubygems/specification.rbs +8 -0
  46. data/core/rubygems/version.rbs +0 -160
  47. data/core/set.rbs +3 -3
  48. data/core/struct.rbs +16 -16
  49. data/core/thread.rbs +9 -14
  50. data/docs/CONTRIBUTING.md +2 -1
  51. data/docs/inline.md +36 -6
  52. data/docs/rbs_by_example.md +20 -20
  53. data/docs/release.md +69 -0
  54. data/docs/syntax.md +2 -2
  55. data/docs/wasm_serialization.md +80 -0
  56. data/ext/rbs_extension/ast_translation.c +1294 -973
  57. data/ext/rbs_extension/ast_translation.h +4 -0
  58. data/ext/rbs_extension/legacy_location.c +11 -6
  59. data/ext/rbs_extension/main.c +139 -4
  60. data/include/rbs/ast.h +9 -1
  61. data/include/rbs/serialize.h +39 -0
  62. data/lib/rbs/ast/ruby/comment_block.rb +6 -4
  63. data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
  64. data/lib/rbs/ast/ruby/members.rb +12 -1
  65. data/lib/rbs/buffer.rb +48 -11
  66. data/lib/rbs/collection/sources/git.rb +6 -0
  67. data/lib/rbs/definition_builder/method_builder.rb +12 -6
  68. data/lib/rbs/environment.rb +4 -3
  69. data/lib/rbs/inline_parser.rb +5 -3
  70. data/lib/rbs/namespace.rb +47 -11
  71. data/lib/rbs/parser_aux.rb +4 -2
  72. data/lib/rbs/prototype/rbi.rb +193 -25
  73. data/lib/rbs/prototype/runtime.rb +2 -0
  74. data/lib/rbs/resolver/type_name_resolver.rb +12 -14
  75. data/lib/rbs/type_name.rb +33 -13
  76. data/lib/rbs/unit_test/type_assertions.rb +9 -0
  77. data/lib/rbs/version.rb +1 -1
  78. data/lib/rbs/wasm/deserializer.rb +213 -0
  79. data/lib/rbs/wasm/location.rb +61 -0
  80. data/lib/rbs/wasm/parser.rb +137 -0
  81. data/lib/rbs/wasm/runtime.rb +196 -0
  82. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  83. data/lib/rbs.rb +13 -2
  84. data/lib/rbs_jars.rb +39 -0
  85. data/lib/rdoc_plugin/parser.rb +5 -0
  86. data/rbs.gemspec +32 -2
  87. data/sig/ast/ruby/members.rbs +6 -1
  88. data/sig/buffer.rbs +19 -1
  89. data/sig/namespace.rbs +20 -0
  90. data/sig/parser.rbs +10 -0
  91. data/sig/prototype/rbi.rbs +33 -4
  92. data/sig/resolver/type_name_resolver.rbs +2 -4
  93. data/sig/typename.rbs +15 -0
  94. data/sig/unit_test/type_assertions.rbs +4 -0
  95. data/sig/wasm/deserializer.rbs +66 -0
  96. data/sig/wasm/serialization_schema.rbs +13 -0
  97. data/src/ast.c +78 -78
  98. data/src/lexer.c +97 -93
  99. data/src/lexer.re +1 -1
  100. data/src/lexstate.c +9 -1
  101. data/src/serialize.c +958 -0
  102. data/src/util/rbs_allocator.c +14 -8
  103. data/stdlib/abbrev/0/array.rbs +1 -1
  104. data/stdlib/csv/0/csv.rbs +5 -5
  105. data/stdlib/delegate/0/delegator.rbs +2 -1
  106. data/stdlib/digest/0/digest.rbs +11 -5
  107. data/stdlib/erb/0/erb.rbs +1 -1
  108. data/stdlib/etc/0/etc.rbs +18 -4
  109. data/stdlib/fileutils/0/fileutils.rbs +21 -21
  110. data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
  111. data/stdlib/json/0/json.rbs +6 -6
  112. data/stdlib/monitor/0/monitor.rbs +2 -2
  113. data/stdlib/openssl/0/openssl.rbs +44 -38
  114. data/stdlib/resolv/0/resolv.rbs +1 -1
  115. data/stdlib/shellwords/0/shellwords.rbs +1 -1
  116. data/stdlib/stringio/0/stringio.rbs +32 -10
  117. data/stdlib/strscan/0/string_scanner.rbs +74 -55
  118. data/stdlib/tempfile/0/manifest.yaml +3 -0
  119. data/stdlib/timeout/0/timeout.rbs +0 -5
  120. data/stdlib/tsort/0/cyclic.rbs +1 -1
  121. data/stdlib/tsort/0/interfaces.rbs +8 -8
  122. data/stdlib/tsort/0/tsort.rbs +9 -9
  123. data/stdlib/uri/0/generic.rbs +0 -5
  124. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  125. data/stdlib/zlib/0/zstream.rbs +0 -1
  126. data/wasm/README.md +60 -0
  127. data/wasm/rbs_wasm.c +423 -0
  128. metadata +26 -5
  129. data/.vscode/extensions.json +0 -5
  130. data/.vscode/settings.json +0 -19
data/core/integer.rbs CHANGED
@@ -93,6 +93,8 @@
93
93
  # given value.
94
94
  #
95
95
  class Integer < Numeric
96
+ # TODO: `undef self.new`
97
+
96
98
  # <!--
97
99
  # rdoc-file=numeric.c
98
100
  # - Integer.sqrt(numeric) -> integer
@@ -421,7 +423,7 @@ class Integer < Numeric
421
423
  #
422
424
  # Related: Integer#eql? (requires `other` to be an Integer).
423
425
  #
424
- def ==: (untyped) -> bool
426
+ def ==: (untyped other) -> bool
425
427
 
426
428
  # <!--
427
429
  # rdoc-file=numeric.c
@@ -434,7 +436,7 @@ class Integer < Numeric
434
436
  #
435
437
  # Related: Integer#eql? (requires `other` to be an Integer).
436
438
  #
437
- def ===: (untyped) -> bool
439
+ alias === ==
438
440
 
439
441
  # <!--
440
442
  # rdoc-file=numeric.c
@@ -687,8 +689,7 @@ class Integer < Numeric
687
689
  # -5| 100000| 0
688
690
  # Related: Integer#floor.
689
691
  #
690
- def ceil: () -> Integer
691
- | (int digits) -> (Integer | Float)
692
+ def ceil: (?int digits) -> Integer
692
693
 
693
694
  # <!--
694
695
  # rdoc-file=numeric.rb
@@ -726,7 +727,7 @@ class Integer < Numeric
726
727
  #
727
728
  # Related: Integer#ord.
728
729
  #
729
- def chr: (?encoding) -> String
730
+ def chr: (?encoding encoding) -> String
730
731
 
731
732
  # <!--
732
733
  # rdoc-file=bignum.c
@@ -749,7 +750,7 @@ class Integer < Numeric
749
750
  # -->
750
751
  # Returns `1`.
751
752
  #
752
- def denominator: () -> Integer
753
+ def denominator: () -> 1
753
754
 
754
755
  # <!--
755
756
  # rdoc-file=numeric.c
@@ -764,7 +765,7 @@ class Integer < Numeric
764
765
  #
765
766
  # Raises an exception if `self` is negative or `base` is less than 2.
766
767
  #
767
- def digits: (?int base) -> ::Array[Integer]
768
+ def digits: (?int base) -> Array[Integer]
768
769
 
769
770
  # <!--
770
771
  # rdoc-file=numeric.c
@@ -912,7 +913,7 @@ class Integer < Numeric
912
913
  # 3.gcd(-7) #=> 1
913
914
  # ((1<<31)-1).gcd((1<<61)-1) #=> 1
914
915
  #
915
- def gcd: (Integer) -> Integer
916
+ def gcd: (Integer other_int) -> Integer
916
917
 
917
918
  # <!--
918
919
  # rdoc-file=rational.c
@@ -926,7 +927,7 @@ class Integer < Numeric
926
927
  # 3.gcdlcm(-7) #=> [1, 21]
927
928
  # ((1<<31)-1).gcdlcm((1<<61)-1) #=> [1, 4951760154835678088235319297]
928
929
  #
929
- def gcdlcm: (Integer) -> [ Integer, Integer ]
930
+ def gcdlcm: (Integer other_int) -> [ Integer, Integer ]
930
931
 
931
932
  # <!-- rdoc-file=numeric.c -->
932
933
  # Returns a string containing the place-value representation of `self` in radix
@@ -964,14 +965,14 @@ class Integer < Numeric
964
965
  # 3.lcm(-7) #=> 21
965
966
  # ((1<<31)-1).lcm((1<<61)-1) #=> 4951760154835678088235319297
966
967
  #
967
- def lcm: (Integer) -> Integer
968
+ def lcm: (Integer other_int) -> Integer
968
969
 
969
970
  # <!--
970
971
  # rdoc-file=numeric.rb
971
972
  # - magnitude()
972
973
  # -->
973
974
  #
974
- def magnitude: () -> Integer
975
+ alias magnitude abs
975
976
 
976
977
  # <!-- rdoc-file=numeric.c -->
977
978
  # Returns `self` modulo `other` as a real numeric (Integer, Float, or Rational).
@@ -1009,7 +1010,7 @@ class Integer < Numeric
1009
1010
  #
1010
1011
  # Related: Integer#pred (predecessor value).
1011
1012
  #
1012
- def next: () -> Integer
1013
+ alias next succ
1013
1014
 
1014
1015
  # <!--
1015
1016
  # rdoc-file=numeric.c
@@ -1040,7 +1041,7 @@ class Integer < Numeric
1040
1041
  # -->
1041
1042
  # Returns `self`.
1042
1043
  #
1043
- def numerator: () -> Integer
1044
+ def numerator: () -> self
1044
1045
 
1045
1046
  # <!--
1046
1047
  # rdoc-file=numeric.rb
@@ -1056,7 +1057,7 @@ class Integer < Numeric
1056
1057
  # -->
1057
1058
  # Returns `self`; intended for compatibility to character literals in Ruby 1.9.
1058
1059
  #
1059
- def ord: () -> Integer
1060
+ def ord: () -> self
1060
1061
 
1061
1062
  def polar: () -> [ Integer, Integer | Float ]
1062
1063
 
@@ -1180,8 +1181,7 @@ class Integer < Numeric
1180
1181
  #
1181
1182
  # Related: Integer#truncate.
1182
1183
  #
1183
- def round: (?half: :up | :down | :even) -> Integer
1184
- | (int digits, ?half: :up | :down | :even) -> (Integer | Float)
1184
+ def round: (?int digits, ?half: Numeric::round_mode) -> Integer
1185
1185
 
1186
1186
  # <!--
1187
1187
  # rdoc-file=numeric.rb
@@ -1226,8 +1226,8 @@ class Integer < Numeric
1226
1226
  #
1227
1227
  # With no block given, returns an Enumerator.
1228
1228
  #
1229
- def times: () { (Integer) -> void } -> self
1230
- | () -> ::Enumerator[Integer, self]
1229
+ def times: () { (Integer i) -> void } -> self
1230
+ | () -> Enumerator[Integer, self]
1231
1231
 
1232
1232
  # <!--
1233
1233
  # rdoc-file=numeric.c
@@ -1251,7 +1251,7 @@ class Integer < Numeric
1251
1251
  # -->
1252
1252
  # Returns `self` (which is already an Integer).
1253
1253
  #
1254
- def to_i: () -> Integer
1254
+ def to_i: () -> self
1255
1255
 
1256
1256
  # <!--
1257
1257
  # rdoc-file=numeric.rb
@@ -1289,43 +1289,7 @@ class Integer < Numeric
1289
1289
  #
1290
1290
  # Raises an exception if `base` is out of range.
1291
1291
  #
1292
- def to_s: () -> String
1293
- | (2) -> String
1294
- | (3) -> String
1295
- | (4) -> String
1296
- | (5) -> String
1297
- | (6) -> String
1298
- | (7) -> String
1299
- | (8) -> String
1300
- | (9) -> String
1301
- | (10) -> String
1302
- | (11) -> String
1303
- | (12) -> String
1304
- | (13) -> String
1305
- | (14) -> String
1306
- | (15) -> String
1307
- | (16) -> String
1308
- | (17) -> String
1309
- | (18) -> String
1310
- | (19) -> String
1311
- | (20) -> String
1312
- | (21) -> String
1313
- | (22) -> String
1314
- | (23) -> String
1315
- | (24) -> String
1316
- | (25) -> String
1317
- | (26) -> String
1318
- | (27) -> String
1319
- | (28) -> String
1320
- | (29) -> String
1321
- | (30) -> String
1322
- | (31) -> String
1323
- | (32) -> String
1324
- | (33) -> String
1325
- | (34) -> String
1326
- | (35) -> String
1327
- | (36) -> String
1328
- | (int base) -> String
1292
+ def to_s: (?int base) -> String
1329
1293
 
1330
1294
  # <!--
1331
1295
  # rdoc-file=numeric.c
@@ -1348,8 +1312,7 @@ class Integer < Numeric
1348
1312
  #
1349
1313
  # Related: Integer#round.
1350
1314
  #
1351
- def truncate: () -> Integer
1352
- | (int ndigits) -> Integer
1315
+ def truncate: (?int ndigits) -> Integer
1353
1316
 
1354
1317
  # <!--
1355
1318
  # rdoc-file=numeric.c
data/core/io.rbs CHANGED
@@ -1230,6 +1230,24 @@ class IO < Object
1230
1230
  #
1231
1231
  def ioctl: (Integer integer_cmd, String | Integer argument) -> Integer
1232
1232
 
1233
+ # <!--
1234
+ # rdoc-file=ext/etc/etc.c
1235
+ # - pathconf(name) -> Integer
1236
+ # -->
1237
+ # Returns pathname configuration variable using fpathconf().
1238
+ #
1239
+ # *name* should be a constant under `Etc` which begins with `PC_`.
1240
+ #
1241
+ # The return value is an integer or nil. nil means indefinite limit.
1242
+ # (fpathconf() returns -1 but errno is not set.)
1243
+ #
1244
+ # require 'etc'
1245
+ # IO.pipe {|r, w|
1246
+ # p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096
1247
+ # }
1248
+ #
1249
+ def pathconf: (Integer name) -> Integer?
1250
+
1233
1251
  # <!--
1234
1252
  # rdoc-file=io.c
1235
1253
  # - isatty -> true or false
@@ -1474,7 +1492,7 @@ class IO < Object
1474
1492
  #
1475
1493
  # Not available on some platforms.
1476
1494
  #
1477
- def pread: (int maxlen, int offset, ?string out_string) -> String
1495
+ def pread: (int maxlen, int offset, ?string? out_string) -> String
1478
1496
 
1479
1497
  # <!--
1480
1498
  # rdoc-file=io.c
@@ -1571,8 +1589,8 @@ class IO < Object
1571
1589
  #
1572
1590
  # Related: IO#write.
1573
1591
  #
1574
- def read: (?nil, ?string outbuf) -> String
1575
- | (int? length, ?string outbuf) -> String?
1592
+ def read: (?nil, ?string? outbuf) -> String
1593
+ | (int? length, ?string? outbuf) -> String?
1576
1594
 
1577
1595
  # <!--
1578
1596
  # rdoc-file=io.rb
@@ -1627,8 +1645,8 @@ class IO < Object
1627
1645
  # symbol <code>:wait_readable</code> instead. At EOF, it will return nil instead
1628
1646
  # of raising EOFError.
1629
1647
  #
1630
- def read_nonblock: (int len, ?string buf, ?exception: true) -> String
1631
- | (int len, ?string buf, exception: false) -> (String | :wait_readable | nil)
1648
+ def read_nonblock: (int len, ?string? buf, ?exception: true) -> String
1649
+ | (int len, ?string? buf, exception: false) -> (String | :wait_readable | nil)
1632
1650
 
1633
1651
  # <!--
1634
1652
  # rdoc-file=io.c
@@ -1828,7 +1846,7 @@ class IO < Object
1828
1846
  # r.readpartial(4096) # => "def\n" "" "ghi\n"
1829
1847
  # r.readpartial(4096) # => "ghi\n" "" ""
1830
1848
  #
1831
- def readpartial: (int maxlen, ?string outbuf) -> String
1849
+ def readpartial: (int maxlen, ?string? outbuf) -> String
1832
1850
 
1833
1851
  # <!--
1834
1852
  # rdoc-file=io.c
@@ -2049,7 +2067,7 @@ class IO < Object
2049
2067
  #
2050
2068
  # This method should not be used with other stream-reader methods.
2051
2069
  #
2052
- def sysread: (Integer maxlen, String outbuf) -> String
2070
+ def sysread: (Integer maxlen, ?String? outbuf) -> String
2053
2071
 
2054
2072
  # <!--
2055
2073
  # rdoc-file=io.c
data/core/match_data.rbs CHANGED
@@ -92,7 +92,7 @@ class MatchData
92
92
  # #<MatchData "hoge" foo:nil foo:"oge" foo:nil>
93
93
  # m[:foo] #=> "oge"
94
94
  #
95
- def []: (capture backref, ?nil) -> String?
95
+ def []: %a{implicitly-returns-nil} (capture backref, ?nil) -> String
96
96
  | (int start, int length) -> Array[String?]
97
97
  | (range[int?] range) -> Array[String?]
98
98