rbs 3.8.1 → 3.9.0.dev.1

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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependabot.yml +1 -1
  3. data/.github/workflows/typecheck.yml +2 -0
  4. data/.github/workflows/windows.yml +15 -0
  5. data/.rubocop.yml +13 -1
  6. data/Rakefile +5 -2
  7. data/config.yml +6 -0
  8. data/core/data.rbs +1 -1
  9. data/core/enumerator.rbs +14 -2
  10. data/core/exception.rbs +1 -1
  11. data/core/gc.rbs +1 -1
  12. data/core/io.rbs +7 -3
  13. data/core/kernel.rbs +2 -2
  14. data/core/method.rbs +2 -2
  15. data/core/module.rbs +3 -3
  16. data/core/proc.rbs +2 -2
  17. data/core/rbs/unnamed/argf.rbs +3 -3
  18. data/core/rubygems/version.rbs +2 -2
  19. data/core/string.rbs +1 -1
  20. data/core/unbound_method.rbs +1 -1
  21. data/docs/syntax.md +10 -5
  22. data/ext/rbs_extension/extconf.rb +2 -1
  23. data/ext/rbs_extension/location.c +32 -10
  24. data/ext/rbs_extension/location.h +4 -3
  25. data/ext/rbs_extension/main.c +22 -1
  26. data/ext/rbs_extension/parser.c +144 -136
  27. data/ext/rbs_extension/parserstate.c +40 -9
  28. data/ext/rbs_extension/parserstate.h +6 -4
  29. data/include/rbs/ruby_objs.h +6 -6
  30. data/include/rbs/util/rbs_constant_pool.h +219 -0
  31. data/lib/rbs/ast/declarations.rb +9 -4
  32. data/lib/rbs/ast/directives.rb +10 -0
  33. data/lib/rbs/ast/members.rb +2 -0
  34. data/lib/rbs/ast/type_param.rb +2 -2
  35. data/lib/rbs/cli/validate.rb +1 -0
  36. data/lib/rbs/cli.rb +3 -3
  37. data/lib/rbs/collection/config/lockfile_generator.rb +28 -7
  38. data/lib/rbs/collection/sources/rubygems.rb +1 -1
  39. data/lib/rbs/definition.rb +46 -31
  40. data/lib/rbs/definition_builder/ancestor_builder.rb +2 -0
  41. data/lib/rbs/definition_builder.rb +86 -30
  42. data/lib/rbs/environment.rb +33 -18
  43. data/lib/rbs/errors.rb +23 -0
  44. data/lib/rbs/locator.rb +2 -0
  45. data/lib/rbs/method_type.rb +2 -0
  46. data/lib/rbs/parser_aux.rb +38 -1
  47. data/lib/rbs/subtractor.rb +3 -3
  48. data/lib/rbs/test/hook.rb +2 -2
  49. data/lib/rbs/test/type_check.rb +7 -5
  50. data/lib/rbs/types.rb +44 -5
  51. data/lib/rbs/unit_test/spy.rb +4 -2
  52. data/lib/rbs/unit_test/type_assertions.rb +17 -11
  53. data/lib/rbs/validator.rb +4 -0
  54. data/lib/rbs/version.rb +1 -1
  55. data/lib/rbs/writer.rb +10 -5
  56. data/lib/rbs.rb +1 -0
  57. data/rbs.gemspec +1 -1
  58. data/sig/collection/config/lockfile_generator.rbs +1 -1
  59. data/sig/declarations.rbs +10 -3
  60. data/sig/definition.rbs +67 -14
  61. data/sig/definition_builder.rbs +17 -3
  62. data/sig/directives.rbs +17 -1
  63. data/sig/environment.rbs +2 -0
  64. data/sig/errors.rbs +16 -0
  65. data/sig/parser.rbs +5 -1
  66. data/sig/subtractor.rbs +1 -1
  67. data/sig/test/type_check.rbs +2 -2
  68. data/sig/type_param.rbs +1 -1
  69. data/sig/types.rbs +3 -0
  70. data/sig/unit_test/spy.rbs +2 -0
  71. data/sig/unit_test/type_assertions.rbs +2 -0
  72. data/sig/validator.rbs +4 -0
  73. data/sig/writer.rbs +1 -1
  74. data/src/ruby_objs.c +12 -6
  75. data/src/util/rbs_constant_pool.c +342 -0
  76. data/stdlib/cgi/0/core.rbs +10 -0
  77. data/stdlib/json/0/json.rbs +52 -50
  78. data/stdlib/net-http/0/net-http.rbs +2 -2
  79. data/stdlib/openssl/0/openssl.rbs +73 -73
  80. data/stdlib/resolv/0/resolv.rbs +8 -8
  81. data/stdlib/socket/0/addrinfo.rbs +1 -1
  82. data/stdlib/socket/0/unix_socket.rbs +4 -2
  83. data/stdlib/stringio/0/stringio.rbs +1 -1
  84. data/stdlib/uri/0/common.rbs +17 -0
  85. metadata +4 -7
  86. data/templates/include/rbs/constants.h.erb +0 -20
  87. data/templates/include/rbs/ruby_objs.h.erb +0 -10
  88. data/templates/src/constants.c.erb +0 -36
  89. data/templates/src/ruby_objs.c.erb +0 -27
  90. data/templates/template.rb +0 -122
@@ -2,26 +2,6 @@ interface _ToJson
2
2
  def to_json: (?JSON::State state) -> String
3
3
  end
4
4
 
5
- interface _JsonToWritableIO
6
- def to_io: () -> _JsonWrite
7
- end
8
-
9
- interface _JsonWrite
10
- def write: (String json) -> void
11
-
12
- def flush: () -> void
13
- end
14
-
15
- interface _JsonReadableIO
16
- def to_io: () -> _JsonRead
17
- end
18
-
19
- interface _JsonRead
20
- def read: () -> string
21
- end
22
-
23
- type json_options = Hash[Symbol, untyped]
24
-
25
5
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
26
6
  # The base exception for JSON errors.
27
7
  #
@@ -96,10 +76,6 @@ end
96
76
  class JSON::Pure::Parser
97
77
  end
98
78
 
99
- type json_generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
100
- type json_parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
101
- type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
102
-
103
79
  # <!-- rdoc-file=ext/json/lib/json.rb -->
104
80
  # # JavaScript Object Notation (JSON)
105
81
  #
@@ -675,6 +651,32 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
675
651
  # With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
676
652
  #
677
653
  module JSON
654
+ type options = Hash[Symbol, untyped]
655
+
656
+ type generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
657
+
658
+ type parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
659
+
660
+ type state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
661
+
662
+ interface _WritableIO
663
+ def to_io: () -> _Write
664
+ end
665
+
666
+ interface _Write
667
+ def write: (String json) -> void
668
+
669
+ def flush: () -> void
670
+ end
671
+
672
+ interface _ReadableIO
673
+ def to_io: () -> _Read
674
+ end
675
+
676
+ interface _Read
677
+ def read: () -> string
678
+ end
679
+
678
680
  # <!--
679
681
  # rdoc-file=ext/json/lib/json/common.rb
680
682
  # - JSON[object] -> new_array or new_string
@@ -689,7 +691,7 @@ module JSON
689
691
  # ruby = [0, 1, nil]
690
692
  # JSON[ruby] # => '[0,1,null]'
691
693
  #
692
- def self.[]: (untyped object, ?json_options opts) -> untyped
694
+ def self.[]: (untyped object, ?options opts) -> untyped
693
695
 
694
696
  # <!--
695
697
  # rdoc-file=ext/json/lib/json/common.rb
@@ -744,22 +746,22 @@ module JSON
744
746
  # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
745
747
  #
746
748
  def self?.dump: (_ToJson obj, ?Integer limit) -> String
747
- | (_ToJson obj, _JsonToWritableIO anIO) -> _JsonWrite
748
- | (_ToJson obj, _JsonWrite anIO, ?Integer limit) -> _JsonWrite
749
+ | (_ToJson obj, _WritableIO anIO) -> _Write
750
+ | (_ToJson obj, _Write anIO, ?Integer limit) -> _Write
749
751
 
750
752
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
751
753
  # Sets or returns the default options for the JSON.dump method. Initially:
752
754
  # opts = JSON.dump_default_options
753
755
  # opts # => {:max_nesting=>false, :allow_nan=>true}
754
756
  #
755
- def self.dump_default_options: () -> json_options
757
+ def self.dump_default_options: () -> options
756
758
 
757
759
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
758
760
  # Sets or returns the default options for the JSON.dump method. Initially:
759
761
  # opts = JSON.dump_default_options
760
762
  # opts # => {:max_nesting=>false, :allow_nan=>true}
761
763
  #
762
- def self.dump_default_options=: (json_options) -> json_options
764
+ def self.dump_default_options=: (options) -> options
763
765
 
764
766
  # <!--
765
767
  # rdoc-file=ext/json/lib/json/common.rb
@@ -776,7 +778,7 @@ module JSON
776
778
  # # Raises SystemStackError (stack level too deep):
777
779
  # JSON.fast_generate(a)
778
780
  #
779
- def self?.fast_generate: (_ToJson obj, ?json_options opts) -> String
781
+ def self?.fast_generate: (_ToJson obj, ?options opts) -> String
780
782
 
781
783
  alias self.fast_unparse self.fast_generate
782
784
 
@@ -819,14 +821,14 @@ module JSON
819
821
  # # Raises JSON::NestingError (nesting of 100 is too deep):
820
822
  # JSON.generate(a)
821
823
  #
822
- def self?.generate: (_ToJson obj, ?json_options opts) -> String
824
+ def self?.generate: (_ToJson obj, ?options opts) -> String
823
825
 
824
826
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
825
827
  # Returns the JSON generator module that is used by JSON.
826
828
  #
827
- def self.generator: () -> json_generator
829
+ def self.generator: () -> generator
828
830
 
829
- def self.generator=: (json_generator generator) -> void
831
+ def self.generator=: (generator generator) -> void
830
832
 
831
833
  # <!--
832
834
  # rdoc-file=ext/json/lib/json/common.rb
@@ -972,7 +974,7 @@ module JSON
972
974
  # #<Admin:0x00000000064c41f8
973
975
  # @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
974
976
  #
975
- def self?.load: (string | _JsonReadableIO | _JsonRead source, ?Proc proc, ?json_options options) -> untyped
977
+ def self?.load: (string | _ReadableIO | _Read source, ?Proc proc, ?options options) -> untyped
976
978
 
977
979
  # <!--
978
980
  # rdoc-file=ext/json/lib/json/common.rb
@@ -983,7 +985,7 @@ module JSON
983
985
  #
984
986
  # See method #parse.
985
987
  #
986
- def self?.load_file: (string path, ?json_options opts) -> untyped
988
+ def self?.load_file: (string path, ?options opts) -> untyped
987
989
 
988
990
  # <!--
989
991
  # rdoc-file=ext/json/lib/json/common.rb
@@ -994,21 +996,21 @@ module JSON
994
996
  #
995
997
  # See method #parse!
996
998
  #
997
- def self?.load_file!: (string path, ?json_options opts) -> untyped
999
+ def self?.load_file!: (string path, ?options opts) -> untyped
998
1000
 
999
1001
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1000
1002
  # Sets or returns default options for the JSON.load method. Initially:
1001
1003
  # opts = JSON.load_default_options
1002
1004
  # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1003
1005
  #
1004
- def self.load_default_options: () -> json_options
1006
+ def self.load_default_options: () -> options
1005
1007
 
1006
1008
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1007
1009
  # Sets or returns default options for the JSON.load method. Initially:
1008
1010
  # opts = JSON.load_default_options
1009
1011
  # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
1010
1012
  #
1011
- def self.load_default_options=: (json_options) -> json_options
1013
+ def self.load_default_options=: (options) -> options
1012
1014
 
1013
1015
  # <!--
1014
1016
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1059,7 +1061,7 @@ module JSON
1059
1061
  # # Raises JSON::ParserError (783: unexpected token at ''):
1060
1062
  # JSON.parse('')
1061
1063
  #
1062
- def self?.parse: (string source, ?json_options opts) -> untyped
1064
+ def self?.parse: (string source, ?options opts) -> untyped
1063
1065
 
1064
1066
  # <!--
1065
1067
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1075,14 +1077,14 @@ module JSON
1075
1077
  # checking for nesting depth.
1076
1078
  # * Option `allow_nan`, if not provided, defaults to `true`.
1077
1079
  #
1078
- def self?.parse!: (string source, ?json_options opts) -> untyped
1080
+ def self?.parse!: (string source, ?options opts) -> untyped
1079
1081
 
1080
1082
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1081
1083
  # Returns the JSON parser class that is used by JSON.
1082
1084
  #
1083
- def self.parser: () -> json_parser
1085
+ def self.parser: () -> parser
1084
1086
 
1085
- def self.parser=: (json_parser parser) -> void
1087
+ def self.parser=: (parser parser) -> void
1086
1088
 
1087
1089
  # <!--
1088
1090
  # rdoc-file=ext/json/lib/json/common.rb
@@ -1116,7 +1118,7 @@ module JSON
1116
1118
  # }
1117
1119
  # }
1118
1120
  #
1119
- def self?.pretty_generate: (_ToJson obj, ?json_options opts) -> untyped
1121
+ def self?.pretty_generate: (_ToJson obj, ?options opts) -> untyped
1120
1122
 
1121
1123
  alias self.pretty_unparse self.pretty_generate
1122
1124
 
@@ -1144,19 +1146,19 @@ module JSON
1144
1146
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1145
1147
  # Sets or Returns the JSON generator state class that is used by JSON.
1146
1148
  #
1147
- def self.state: () -> json_state
1149
+ def self.state: () -> state
1148
1150
 
1149
1151
  # <!-- rdoc-file=ext/json/lib/json/common.rb -->
1150
1152
  # Sets or Returns the JSON generator state class that is used by JSON.
1151
1153
  #
1152
- def self.state=: (json_state) -> json_state
1154
+ def self.state=: (state) -> state
1153
1155
 
1154
1156
  alias self.unparse self.generate
1155
1157
 
1156
1158
  alias unparse generate
1157
1159
  end
1158
1160
 
1159
- JSON::FAST_STATE_PROTOTYPE: json_state
1161
+ JSON::FAST_STATE_PROTOTYPE: JSON::state
1160
1162
 
1161
1163
  JSON::Infinity: Float
1162
1164
 
@@ -1166,9 +1168,9 @@ JSON::MinusInfinity: Float
1166
1168
 
1167
1169
  JSON::NaN: Float
1168
1170
 
1169
- JSON::PRETTY_STATE_PROTOTYPE: json_state
1171
+ JSON::PRETTY_STATE_PROTOTYPE: JSON::state
1170
1172
 
1171
- JSON::SAFE_STATE_PROTOTYPE: json_state
1173
+ JSON::SAFE_STATE_PROTOTYPE: JSON::state
1172
1174
 
1173
1175
  JSON::VERSION: String
1174
1176
 
@@ -1213,8 +1215,8 @@ module Kernel
1213
1215
  # The *opts* argument is passed through to generate/parse respectively. See
1214
1216
  # generate and parse for their documentation.
1215
1217
  #
1216
- def JSON: (string source, ?json_options opts) -> untyped
1217
- | (_ToJson obj, ?json_options opts) -> String
1218
+ def JSON: (string source, ?JSON::options opts) -> untyped
1219
+ | (_ToJson obj, ?JSON::options opts) -> String
1218
1220
  end
1219
1221
 
1220
1222
  %a{annotate:rdoc:skip}
@@ -978,8 +978,8 @@ module Net
978
978
  # Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value
979
979
  # passed to `new` is Net::HTTP.https_default_port, not `port`.
980
980
  #
981
- def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]? opt) -> Net::HTTP
982
- | [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]? opt) { (Net::HTTP) -> T } -> T
981
+ def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]?, **untyped opt) -> Net::HTTP
982
+ | [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]?, **untyped opt) { (Net::HTTP) -> T } -> T
983
983
 
984
984
  # <!--
985
985
  # rdoc-file=lib/net/http.rb