steep 1.0.2 → 1.1.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +22 -3
- data/Gemfile +6 -3
- data/Gemfile.lock +12 -16
- data/Gemfile.steep +3 -0
- data/Gemfile.steep.lock +49 -0
- data/Rakefile +5 -0
- data/Steepfile +6 -1
- data/bin/setup +2 -0
- data/bin/steep +19 -0
- data/lib/steep/ast/types/factory.rb +1 -1
- data/lib/steep/diagnostic/ruby.rb +49 -3
- data/lib/steep/diagnostic/signature.rb +18 -0
- data/lib/steep/drivers/watch.rb +3 -1
- data/lib/steep/method_name.rb +9 -3
- data/lib/steep/node_helper.rb +49 -0
- data/lib/steep/services/completion_provider.rb +22 -15
- data/lib/steep/services/hover_provider/ruby.rb +30 -12
- data/lib/steep/services/type_check_service.rb +12 -12
- data/lib/steep/shims/symbol_start_with.rb +18 -0
- data/lib/steep/signature/validator.rb +19 -0
- data/lib/steep/subtyping/constraints.rb +43 -14
- data/lib/steep/type_construction.rb +666 -746
- data/lib/steep/type_inference/constant_env.rb +0 -2
- data/lib/steep/type_inference/context.rb +23 -17
- data/lib/steep/type_inference/logic_type_interpreter.rb +210 -119
- data/lib/steep/type_inference/method_call.rb +80 -6
- data/lib/steep/type_inference/multiple_assignment.rb +189 -0
- data/lib/steep/type_inference/type_env.rb +271 -120
- data/lib/steep/type_inference/type_env_builder.rb +138 -0
- data/lib/steep/typing.rb +2 -0
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +4 -3
- data/rbs_collection.steep.lock.yaml +112 -0
- data/rbs_collection.steep.yaml +19 -0
- data/sample/sig/conference.rbs +8 -0
- data/sig/shims/parser/source/map.rbs +146 -0
- data/sig/shims/parser/source/range.rbs +237 -0
- data/sig/shims/parser.rbs +17 -0
- data/sig/steep/ast/annotation/collection.rbs +75 -0
- data/sig/steep/ast/annotation.rbs +126 -0
- data/sig/steep/ast/builtin.rbs +69 -0
- data/sig/steep/ast/type_params.rbs +11 -0
- data/sig/steep/ast/types/any.rbs +29 -0
- data/sig/steep/ast/types/boolean.rbs +31 -0
- data/sig/steep/ast/types/bot.rbs +29 -0
- data/sig/steep/ast/types/class.rbs +29 -0
- data/sig/steep/ast/types/factory.rbs +76 -0
- data/sig/steep/ast/types/helper.rbs +19 -0
- data/sig/steep/ast/types/instance.rbs +29 -0
- data/sig/steep/ast/types/intersection.rbs +35 -0
- data/sig/steep/ast/types/literal.rbs +33 -0
- data/sig/steep/ast/types/logic.rbs +78 -0
- data/sig/steep/ast/types/name.rbs +71 -0
- data/sig/steep/ast/types/nil.rbs +31 -0
- data/sig/steep/ast/types/proc.rbs +46 -0
- data/sig/steep/ast/types/record.rbs +38 -0
- data/sig/steep/ast/types/self.rbs +29 -0
- data/sig/steep/ast/types/top.rbs +29 -0
- data/sig/steep/ast/types/tuple.rbs +34 -0
- data/sig/steep/ast/types/union.rbs +38 -0
- data/sig/steep/ast/types/var.rbs +37 -0
- data/sig/steep/ast/types/void.rbs +29 -0
- data/sig/steep/ast/types.rbs +37 -0
- data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +15 -0
- data/sig/steep/diagnostic/helper.rbs +9 -0
- data/sig/steep/diagnostic/lsp_formatter.rbs +29 -0
- data/sig/steep/diagnostic/ruby.rbs +494 -0
- data/sig/steep/diagnostic/signature.rbs +215 -0
- data/sig/steep/interface/block.rbs +35 -0
- data/sig/steep/interface/function.rbs +253 -0
- data/sig/steep/interface/interface.rbs +23 -0
- data/sig/steep/interface/method_type.rbs +55 -0
- data/sig/steep/interface/substitution.rbs +53 -0
- data/sig/steep/interface/type_param.rbs +35 -0
- data/sig/steep/method_name.rbs +26 -0
- data/sig/steep/module_helper.rbs +7 -0
- data/sig/steep/node_helper.rbs +11 -0
- data/sig/steep/project/dsl.rbs +94 -0
- data/sig/steep/project/options.rbs +15 -0
- data/sig/steep/project/pattern.rbs +25 -0
- data/sig/steep/project/target.rbs +25 -0
- data/sig/steep/project.rbs +19 -0
- data/sig/steep/services/completion_provider.rbs +123 -0
- data/sig/steep/services/content_change.rbs +35 -0
- data/sig/steep/services/file_loader.rbs +13 -0
- data/sig/steep/services/goto_service.rbs +45 -0
- data/sig/steep/services/hover_provider/rbs.rbs +21 -0
- data/sig/steep/services/hover_provider/ruby.rbs +109 -0
- data/sig/steep/services/hover_provider/singleton_methods.rbs +11 -0
- data/sig/steep/services/path_assignment.rbs +21 -0
- data/sig/steep/services/signature_service.rbs +91 -0
- data/sig/steep/services/stats_calculator.rbs +17 -0
- data/sig/steep/services/type_check_service.rbs +93 -0
- data/sig/steep/source.rbs +55 -0
- data/sig/steep/subtyping/cache.rbs +17 -0
- data/sig/steep/subtyping/check.rbs +93 -0
- data/sig/steep/subtyping/constraints.rbs +111 -0
- data/sig/steep/subtyping/relation.rbs +51 -0
- data/sig/steep/subtyping/result.rbs +157 -0
- data/sig/steep/subtyping/variable_variance.rbs +23 -0
- data/sig/steep/type_construction.rbs +285 -0
- data/sig/steep/type_inference/block_params.rbs +52 -0
- data/sig/steep/type_inference/constant_env.rbs +27 -0
- data/sig/steep/type_inference/context.rbs +137 -0
- data/sig/steep/type_inference/logic_type_interpreter.rbs +72 -0
- data/sig/steep/type_inference/method_call.rbs +124 -0
- data/sig/steep/type_inference/method_params.rbs +104 -0
- data/sig/steep/type_inference/multiple_assignment.rbs +76 -0
- data/sig/steep/type_inference/type_env.rbs +158 -0
- data/sig/steep/type_inference/type_env_builder.rbs +77 -0
- data/sig/steep/typing.rbs +68 -0
- data/sig/steep.rbs +31 -0
- data/smoke/class/f.rb +1 -0
- data/smoke/class/test_expectations.yml +2 -2
- data/smoke/diagnostics/test_expectations.yml +4 -2
- metadata +90 -6
- data/lib/steep/type_inference/local_variable_type_env.rb +0 -249
- data/lib/steep/type_inference/logic.rb +0 -161
@@ -0,0 +1,71 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
module Name
|
5
|
+
class Base
|
6
|
+
attr_reader location: untyped
|
7
|
+
|
8
|
+
attr_reader name: untyped
|
9
|
+
|
10
|
+
def initialize: (name: untyped, ?location: untyped?) -> void
|
11
|
+
|
12
|
+
include Helper::NoFreeVariables
|
13
|
+
|
14
|
+
def subst: (untyped s) -> self
|
15
|
+
|
16
|
+
def level: () -> ::Array[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
class Applying < Base
|
20
|
+
attr_reader args: untyped
|
21
|
+
|
22
|
+
def initialize: (name: untyped, args: untyped, ?location: untyped?) -> void
|
23
|
+
|
24
|
+
def ==: (untyped other) -> untyped
|
25
|
+
|
26
|
+
alias eql? ==
|
27
|
+
|
28
|
+
def hash: () -> untyped
|
29
|
+
|
30
|
+
def to_s: () -> ::String
|
31
|
+
|
32
|
+
def with_location: (untyped new_location) -> untyped
|
33
|
+
|
34
|
+
def subst: (untyped s) -> (untyped | self)
|
35
|
+
|
36
|
+
def free_variables: () -> untyped
|
37
|
+
|
38
|
+
def each_child: () ?{ () -> untyped } -> untyped
|
39
|
+
|
40
|
+
include Helper::ChildrenLevel
|
41
|
+
|
42
|
+
def level: () -> untyped
|
43
|
+
end
|
44
|
+
|
45
|
+
class Singleton < Base
|
46
|
+
def ==: (untyped other) -> untyped
|
47
|
+
|
48
|
+
alias eql? ==
|
49
|
+
|
50
|
+
def hash: () -> untyped
|
51
|
+
|
52
|
+
def to_s: () -> ::String
|
53
|
+
|
54
|
+
def with_location: (untyped new_location) -> untyped
|
55
|
+
|
56
|
+
include Helper::NoChild
|
57
|
+
end
|
58
|
+
|
59
|
+
class Instance < Applying
|
60
|
+
def to_module: () -> untyped
|
61
|
+
end
|
62
|
+
|
63
|
+
class Interface < Applying
|
64
|
+
end
|
65
|
+
|
66
|
+
class Alias < Applying
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Nil
|
5
|
+
attr_reader location: untyped
|
6
|
+
|
7
|
+
def initialize: (?location: untyped?) -> void
|
8
|
+
|
9
|
+
def ==: (untyped other) -> untyped
|
10
|
+
|
11
|
+
def hash: () -> untyped
|
12
|
+
|
13
|
+
alias eql? ==
|
14
|
+
|
15
|
+
def subst: (untyped s) -> self
|
16
|
+
|
17
|
+
def to_s: () -> "nil"
|
18
|
+
|
19
|
+
include Helper::NoFreeVariables
|
20
|
+
|
21
|
+
include Helper::NoChild
|
22
|
+
|
23
|
+
def level: () -> ::Array[0]
|
24
|
+
|
25
|
+
def with_location: (untyped new_location) -> untyped
|
26
|
+
|
27
|
+
def back_type: () -> untyped
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Proc
|
5
|
+
attr_reader location: untyped
|
6
|
+
|
7
|
+
attr_reader type: Interface::Function
|
8
|
+
|
9
|
+
attr_reader block: Interface::Block?
|
10
|
+
|
11
|
+
def initialize: (type: Interface::Function, block: Interface::Block?, ?location: untyped) -> void
|
12
|
+
|
13
|
+
def ==: (untyped other) -> bool
|
14
|
+
|
15
|
+
def hash: () -> Integer
|
16
|
+
|
17
|
+
alias eql? ==
|
18
|
+
|
19
|
+
def subst: (Interface::Substitution s) -> Proc
|
20
|
+
|
21
|
+
def to_s: () -> ::String
|
22
|
+
|
23
|
+
def free_variables: () -> Set[Symbol]
|
24
|
+
|
25
|
+
include Helper::ChildrenLevel
|
26
|
+
|
27
|
+
def level: () -> Array[Integer]
|
28
|
+
|
29
|
+
def closed?: () -> bool
|
30
|
+
|
31
|
+
def with_location: (untyped new_location) -> Proc
|
32
|
+
|
33
|
+
def map_type: () { (AST::Types::t) -> AST::Types::t } -> Proc
|
34
|
+
|
35
|
+
def one_arg?: () -> bool
|
36
|
+
|
37
|
+
def back_type: () -> AST::Types::t
|
38
|
+
|
39
|
+
def block_required?: () -> bool
|
40
|
+
|
41
|
+
def each_child: () { (AST::Types::t) -> void } -> void
|
42
|
+
| () -> Enumerator[AST::Types::t, void]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Record
|
5
|
+
type loc = RBS::Location[untyped, untyped]
|
6
|
+
|
7
|
+
type key = Symbol | String | Integer
|
8
|
+
|
9
|
+
attr_reader location: loc?
|
10
|
+
|
11
|
+
attr_reader elements: Hash[key, t]
|
12
|
+
|
13
|
+
def initialize: (elements: Hash[key, t], ?location: loc?) -> void
|
14
|
+
|
15
|
+
def ==: (untyped other) -> bool
|
16
|
+
|
17
|
+
def hash: () -> Integer
|
18
|
+
|
19
|
+
alias eql? ==
|
20
|
+
|
21
|
+
def subst: (Interface::Substitution s) -> self
|
22
|
+
|
23
|
+
def to_s: () -> ::String
|
24
|
+
|
25
|
+
def free_variables: () -> Set[Symbol]
|
26
|
+
|
27
|
+
include Helper::ChildrenLevel
|
28
|
+
|
29
|
+
def each_child: () { (t) -> void } -> void
|
30
|
+
| () -> Enumerator[t, void]
|
31
|
+
|
32
|
+
def level: () -> Integer
|
33
|
+
|
34
|
+
def with_location: (loc new_location) -> self
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Self
|
5
|
+
attr_reader location: untyped
|
6
|
+
|
7
|
+
def initialize: (?location: untyped?) -> void
|
8
|
+
|
9
|
+
def ==: (untyped other) -> untyped
|
10
|
+
|
11
|
+
def hash: () -> untyped
|
12
|
+
|
13
|
+
alias eql? ==
|
14
|
+
|
15
|
+
def to_s: () -> "self"
|
16
|
+
|
17
|
+
include Helper::NoChild
|
18
|
+
|
19
|
+
def subst: (untyped s) -> untyped
|
20
|
+
|
21
|
+
def free_variables: () -> untyped
|
22
|
+
|
23
|
+
def level: () -> ::Array[0]
|
24
|
+
|
25
|
+
def with_location: (untyped new_location) -> untyped
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Top
|
5
|
+
attr_reader location: untyped
|
6
|
+
|
7
|
+
def initialize: (?location: untyped?) -> void
|
8
|
+
|
9
|
+
def ==: (untyped other) -> untyped
|
10
|
+
|
11
|
+
def hash: () -> untyped
|
12
|
+
|
13
|
+
alias eql? ==
|
14
|
+
|
15
|
+
def subst: (untyped s) -> self
|
16
|
+
|
17
|
+
def to_s: () -> "top"
|
18
|
+
|
19
|
+
include Helper::NoFreeVariables
|
20
|
+
|
21
|
+
include Helper::NoChild
|
22
|
+
|
23
|
+
def level: () -> ::Array[2]
|
24
|
+
|
25
|
+
def with_location: (untyped new_location) -> untyped
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Tuple
|
5
|
+
attr_reader types: Array[t]
|
6
|
+
|
7
|
+
attr_reader location: RBS::Location[untyped, untyped]?
|
8
|
+
|
9
|
+
def initialize: (types: Array[t], ?location: RBS::Location[untyped, untyped]?) -> void
|
10
|
+
|
11
|
+
def ==: (untyped other) -> bool
|
12
|
+
|
13
|
+
def hash: () -> Integer
|
14
|
+
|
15
|
+
alias eql? ==
|
16
|
+
|
17
|
+
def subst: (Interface::Substitution s) -> Tuple
|
18
|
+
|
19
|
+
def to_s: () -> ::String
|
20
|
+
|
21
|
+
def free_variables: () -> Set[Symbol]
|
22
|
+
|
23
|
+
include Helper::ChildrenLevel
|
24
|
+
|
25
|
+
def each_child: () { (t) -> void } -> void
|
26
|
+
| () -> Enumerator[t, void]
|
27
|
+
|
28
|
+
def level: () -> untyped
|
29
|
+
|
30
|
+
def with_location: (RBS::Location[untyped, untyped] new_location) -> Tuple
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Union
|
5
|
+
attr_reader types: Array[t]
|
6
|
+
|
7
|
+
type loc = RBS::Location[untyped, untyped]
|
8
|
+
|
9
|
+
attr_reader location: loc?
|
10
|
+
|
11
|
+
def initialize: (types: Array[t], ?location: loc?) -> void
|
12
|
+
|
13
|
+
def self.build: (types: Array[t], ?location: loc?) -> t
|
14
|
+
|
15
|
+
def ==: (untyped other) -> bool
|
16
|
+
|
17
|
+
def hash: () -> Integer
|
18
|
+
|
19
|
+
alias eql? ==
|
20
|
+
|
21
|
+
def subst: (Interface::Substitution s) -> Union
|
22
|
+
|
23
|
+
def to_s: () -> ::String
|
24
|
+
|
25
|
+
def free_variables: () -> Set[Symbol]
|
26
|
+
|
27
|
+
def each_child: () { (t) -> void } -> void
|
28
|
+
| () -> Enumerator[t, void]
|
29
|
+
|
30
|
+
include Helper::ChildrenLevel
|
31
|
+
|
32
|
+
def level: () -> Integer
|
33
|
+
|
34
|
+
def with_location: (loc new_location) -> Union
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Var
|
5
|
+
attr_reader name: untyped
|
6
|
+
|
7
|
+
attr_reader location: untyped
|
8
|
+
|
9
|
+
def initialize: (name: untyped, ?location: untyped?) -> void
|
10
|
+
|
11
|
+
def ==: (untyped other) -> untyped
|
12
|
+
|
13
|
+
def hash: () -> untyped
|
14
|
+
|
15
|
+
alias eql? ==
|
16
|
+
|
17
|
+
def self.fresh_name: (untyped name) -> untyped
|
18
|
+
|
19
|
+
def self.fresh: (untyped name, ?location: untyped?) -> untyped
|
20
|
+
|
21
|
+
def to_s: () -> untyped
|
22
|
+
|
23
|
+
def subst: (untyped s) -> (untyped | self)
|
24
|
+
|
25
|
+
def free_variables: () -> untyped
|
26
|
+
|
27
|
+
include Helper::NoChild
|
28
|
+
|
29
|
+
def level: () -> ::Array[0]
|
30
|
+
|
31
|
+
def update: (?name: untyped, ?location: untyped) -> untyped
|
32
|
+
|
33
|
+
def with_location: (untyped new_location) -> untyped
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
class Void
|
5
|
+
attr_reader location: untyped
|
6
|
+
|
7
|
+
def initialize: (?location: untyped?) -> void
|
8
|
+
|
9
|
+
def ==: (untyped other) -> untyped
|
10
|
+
|
11
|
+
def hash: () -> untyped
|
12
|
+
|
13
|
+
alias eql? ==
|
14
|
+
|
15
|
+
def subst: (untyped s) -> self
|
16
|
+
|
17
|
+
def to_s: () -> "void"
|
18
|
+
|
19
|
+
include Helper::NoFreeVariables
|
20
|
+
|
21
|
+
include Helper::NoChild
|
22
|
+
|
23
|
+
def level: () -> ::Array[0]
|
24
|
+
|
25
|
+
def with_location: (untyped new_location) -> untyped
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Steep
|
2
|
+
module AST
|
3
|
+
module Types
|
4
|
+
type t = Any | Boolean | Bot | Nil | Top | Void | Literal
|
5
|
+
| Class | Instance | Self
|
6
|
+
| Intersection | Record | Tuple | Union
|
7
|
+
| Name::Alias | Name::Instance | Name::Interface | Name::Singleton
|
8
|
+
| Proc | Var | Logic::Base
|
9
|
+
|
10
|
+
class Masked
|
11
|
+
attr_reader location: untyped
|
12
|
+
|
13
|
+
attr_reader type: untyped
|
14
|
+
|
15
|
+
attr_reader mask: untyped
|
16
|
+
|
17
|
+
def initialize: (type: untyped, mask: untyped, location: untyped) -> void
|
18
|
+
|
19
|
+
def ==: (untyped other) -> untyped
|
20
|
+
|
21
|
+
alias eql? ==
|
22
|
+
|
23
|
+
def hash: () -> untyped
|
24
|
+
|
25
|
+
def to_json: (*untyped a) -> untyped
|
26
|
+
|
27
|
+
def to_s: (?::Integer level) -> ::String
|
28
|
+
|
29
|
+
def free_variables: () -> untyped
|
30
|
+
|
31
|
+
def each_type: () { (untyped) -> untyped } -> untyped
|
32
|
+
|
33
|
+
def sub: (untyped s) -> untyped
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Steep
|
2
|
+
module Diagnostic
|
3
|
+
module Ruby
|
4
|
+
class UnknownConstantAssigned < Base
|
5
|
+
attr_reader context: untyped
|
6
|
+
|
7
|
+
attr_reader name: untyped
|
8
|
+
|
9
|
+
def initialize: (node: untyped, context: untyped, name: untyped) -> void
|
10
|
+
|
11
|
+
def header_line: () -> ::String
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Steep
|
2
|
+
module Diagnostic
|
3
|
+
class LSPFormatter
|
4
|
+
LSP: untyped
|
5
|
+
|
6
|
+
attr_reader config: untyped
|
7
|
+
|
8
|
+
attr_reader default_severity: untyped
|
9
|
+
|
10
|
+
ERROR: :error
|
11
|
+
|
12
|
+
WARNING: :warning
|
13
|
+
|
14
|
+
INFORMATION: :information
|
15
|
+
|
16
|
+
HINT: :hint
|
17
|
+
|
18
|
+
def initialize: (?::Hash[untyped, untyped] config, ?default_severity: untyped) -> void
|
19
|
+
|
20
|
+
def validate_class: (untyped klass) -> (untyped | nil)
|
21
|
+
|
22
|
+
def validate_severity: (untyped klass, untyped severity) -> untyped
|
23
|
+
|
24
|
+
def format: (untyped diagnostic) -> untyped
|
25
|
+
|
26
|
+
def severity_for: (untyped diagnostic) -> untyped
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|