rbs 3.9.5 → 3.10.0.pre.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.
- checksums.yaml +4 -4
- data/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +54 -0
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +34 -19
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +4 -0
- data/README.md +38 -1
- data/Rakefile +152 -23
- data/config.yml +190 -62
- data/core/array.rbs +44 -43
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +3 -2
- data/core/enumerable.rbs +89 -2
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +3 -3
- data/core/file.rbs +26 -11
- data/core/float.rbs +1 -1
- data/core/gc.rbs +422 -281
- data/core/hash.rbs +1024 -727
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +6 -4
- data/core/kernel.rbs +49 -43
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +14 -6
- data/core/module.rbs +71 -11
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +8 -8
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +13 -0
- data/{stdlib/pathname/0 → core}/pathname.rbs +253 -352
- data/core/proc.rbs +15 -8
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +278 -437
- data/core/range.rbs +6 -7
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -2
- data/core/regexp.rbs +22 -17
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/set.rbs +439 -332
- data/core/string.rbs +2897 -1117
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +4 -4
- data/core/thread.rbs +83 -20
- data/core/time.rbs +35 -9
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/gem.md +0 -1
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1016 -0
- data/ext/rbs_extension/ast_translation.h +37 -0
- data/ext/rbs_extension/class_constants.c +157 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +25 -1
- data/ext/rbs_extension/legacy_location.c +317 -0
- data/ext/rbs_extension/legacy_location.h +45 -0
- data/ext/rbs_extension/main.c +365 -14
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +687 -0
- data/include/rbs/defines.h +86 -0
- data/include/rbs/lexer.h +199 -0
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +135 -0
- data/include/rbs/string.h +49 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -67
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +23 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +1 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
- data/lib/rbs/environment.rb +64 -59
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +1 -1
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +124 -38
- data/lib/rbs/test/type_check.rb +13 -0
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +3 -3
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/environment.rbs +57 -6
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +20 -0
- data/sig/resolver/type_name_resolver.rbs +38 -7
- data/sig/types.rbs +4 -1
- data/src/ast.c +1256 -0
- data/src/lexer.c +2956 -0
- data/src/lexer.re +147 -0
- data/src/lexstate.c +205 -0
- data/src/location.c +71 -0
- data/src/parser.c +3495 -0
- data/src/string.c +90 -0
- data/src/util/rbs_allocator.c +152 -0
- data/src/util/rbs_assert.c +21 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +16 -86
- data/src/util/rbs_encoding.c +21308 -0
- data/src/util/rbs_unescape.c +131 -0
- data/stdlib/cgi/0/core.rbs +2 -396
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +153 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +18 -13
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +67 -48
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +8 -3
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/openssl/0/openssl.rbs +182 -149
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +5 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +412 -80
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +11 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -15
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +41 -18
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
data/sig/parser.rbs
CHANGED
|
@@ -68,6 +68,24 @@ module RBS
|
|
|
68
68
|
#
|
|
69
69
|
def self.parse_signature: (Buffer | String) -> [Buffer, Array[AST::Directives::t], Array[AST::Declarations::t]]
|
|
70
70
|
|
|
71
|
+
# Parse a list of type parameters and return it
|
|
72
|
+
#
|
|
73
|
+
# ```ruby
|
|
74
|
+
# RBS::Parser.parse_type_params("") # => nil
|
|
75
|
+
# RBS::Parser.parse_type_params("[U, V]") # => `[:U, :V]`
|
|
76
|
+
# RBS::Parser.parse_type_params("[in U, V < Integer]") # => `[:U, :V]`
|
|
77
|
+
# ```
|
|
78
|
+
#
|
|
79
|
+
# When `module_type_params` is `false`, an error is raised if `unchecked`, `in` or `out` are used.
|
|
80
|
+
#
|
|
81
|
+
# ```ruby
|
|
82
|
+
# RBS::Parser.parse_type_params("[unchecked U]", module_type_params: false) # => Raises an error
|
|
83
|
+
# RBS::Parser.parse_type_params("[out U]", module_type_params: false) # => Raises an error
|
|
84
|
+
# RBS::Parser.parse_type_params("[in U]", module_type_params: false) # => Raises an error
|
|
85
|
+
# ```
|
|
86
|
+
#
|
|
87
|
+
def self.parse_type_params: (Buffer | String, ?module_type_params: bool) -> Array[AST::TypeParam]
|
|
88
|
+
|
|
71
89
|
# Returns the magic comment from the buffer
|
|
72
90
|
#
|
|
73
91
|
def self.magic_comment: (Buffer) -> AST::Directives::ResolveTypeNames?
|
|
@@ -92,6 +110,8 @@ module RBS
|
|
|
92
110
|
|
|
93
111
|
def self._parse_signature: (Buffer, Integer start_pos, Integer end_pos) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
|
|
94
112
|
|
|
113
|
+
def self._parse_type_params: (Buffer, Integer start_pos, Integer end_pos, bool module_type_params) -> Array[AST::TypeParam]
|
|
114
|
+
|
|
95
115
|
def self._lex: (Buffer, Integer end_pos) -> Array[[Symbol, Location[untyped, untyped]]]
|
|
96
116
|
|
|
97
117
|
class LocatedValue
|
|
@@ -8,28 +8,59 @@ module RBS
|
|
|
8
8
|
class TypeNameResolver
|
|
9
9
|
type query = [TypeName, context]
|
|
10
10
|
|
|
11
|
-
def initialize: (
|
|
11
|
+
def initialize: (Set[TypeName] all_names, Hash[TypeName, [TypeName, context]] aliases) -> void
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
def self.new: %a{deprecated: Use `build` to build TypeNameResolver from Environment} (Environment) -> instance
|
|
14
|
+
| (Set[TypeName] all_names, Hash[TypeName, [TypeName, context]] aliases) -> instance
|
|
15
|
+
|
|
16
|
+
def self.build: (Environment) -> instance
|
|
17
|
+
|
|
18
|
+
# Translates given type name to absolute type name
|
|
19
|
+
#
|
|
14
20
|
# Returns `nil` if cannot find associated type name.
|
|
21
|
+
# Module names in the type name are normalized.
|
|
15
22
|
#
|
|
16
23
|
def resolve: (TypeName, context: context) -> TypeName?
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
# Translates given type name to absolute type name
|
|
26
|
+
#
|
|
27
|
+
# Returns `false` if a cycle is detected while resolving aliases.
|
|
28
|
+
# Returns `nil` if the type name cannot be resolved.
|
|
29
|
+
#
|
|
30
|
+
def resolve_namespace: (TypeName, context: context) -> (TypeName | false | nil)
|
|
19
31
|
|
|
20
|
-
|
|
32
|
+
private
|
|
21
33
|
|
|
22
34
|
attr_reader all_names: Set[TypeName]
|
|
23
35
|
|
|
36
|
+
attr_reader aliases: Hash[TypeName, [TypeName, context]]
|
|
37
|
+
|
|
24
38
|
attr_reader cache: Hash[query, TypeName?]
|
|
25
39
|
|
|
26
|
-
|
|
40
|
+
# Returns the type name if it exists in `all_names` (normalized)
|
|
41
|
+
#
|
|
42
|
+
def has_type_name?: (TypeName) -> TypeName?
|
|
43
|
+
|
|
44
|
+
# Returns the type name if it is an alias (not normalized)
|
|
45
|
+
#
|
|
46
|
+
def aliased_name?: (TypeName) -> TypeName?
|
|
27
47
|
|
|
28
48
|
def try_cache: (query) { () -> TypeName? } -> TypeName?
|
|
29
49
|
|
|
30
|
-
|
|
50
|
+
# Translates the head module name in the context and returns an absolute type name
|
|
51
|
+
#
|
|
52
|
+
# Returns `nil` if cannot find associated type name.
|
|
53
|
+
# The returned namespace may be an alias
|
|
54
|
+
#
|
|
55
|
+
def resolve_head_namespace: (Symbol, context) -> TypeName?
|
|
56
|
+
|
|
57
|
+
# Resolves the type name in the given context
|
|
58
|
+
#
|
|
59
|
+
def resolve_type_name: (Symbol, context) -> TypeName?
|
|
60
|
+
|
|
61
|
+
def resolve_namespace0: (TypeName, context, Set[TypeName]) -> (TypeName | false | nil)
|
|
31
62
|
|
|
32
|
-
def
|
|
63
|
+
def normalize_namespace: (TypeName, TypeName rhs, context, Set[TypeName]) -> (TypeName | false | nil)
|
|
33
64
|
end
|
|
34
65
|
end
|
|
35
66
|
end
|
data/sig/types.rbs
CHANGED
|
@@ -518,7 +518,10 @@ module RBS
|
|
|
518
518
|
|
|
519
519
|
attr_reader self_type: t?
|
|
520
520
|
|
|
521
|
-
|
|
521
|
+
type loc = Location[bot, bot]
|
|
522
|
+
attr_reader location: loc?
|
|
523
|
+
|
|
524
|
+
def initialize: (?location: loc?, type: function, ?self_type: t?, required: boolish) -> void
|
|
522
525
|
|
|
523
526
|
def ==: (untyped other) -> bool
|
|
524
527
|
|