steep 1.0.0 → 1.1.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-windows.yml +34 -0
  3. data/.github/workflows/ruby.yml +7 -2
  4. data/.gitignore +1 -0
  5. data/CHANGELOG.md +59 -0
  6. data/Gemfile +7 -4
  7. data/Gemfile.lock +17 -21
  8. data/Gemfile.steep +3 -0
  9. data/Gemfile.steep.lock +49 -0
  10. data/Rakefile +5 -0
  11. data/Steepfile +6 -1
  12. data/bin/setup +2 -0
  13. data/bin/steep +19 -0
  14. data/lib/steep/ast/builtin.rb +2 -2
  15. data/lib/steep/ast/types/factory.rb +7 -3
  16. data/lib/steep/ast/types/proc.rb +2 -0
  17. data/lib/steep/cli.rb +3 -1
  18. data/lib/steep/diagnostic/ruby.rb +50 -4
  19. data/lib/steep/diagnostic/signature.rb +18 -0
  20. data/lib/steep/drivers/check.rb +3 -3
  21. data/lib/steep/drivers/watch.rb +3 -1
  22. data/lib/steep/method_name.rb +9 -3
  23. data/lib/steep/node_helper.rb +49 -0
  24. data/lib/steep/path_helper.rb +22 -0
  25. data/lib/steep/project.rb +3 -15
  26. data/lib/steep/server/base_worker.rb +1 -0
  27. data/lib/steep/server/change_buffer.rb +1 -1
  28. data/lib/steep/server/interaction_worker.rb +3 -5
  29. data/lib/steep/server/master.rb +61 -45
  30. data/lib/steep/server/type_check_worker.rb +10 -25
  31. data/lib/steep/services/completion_provider.rb +25 -18
  32. data/lib/steep/services/goto_service.rb +2 -4
  33. data/lib/steep/services/hover_provider/rbs.rb +1 -1
  34. data/lib/steep/services/hover_provider/ruby.rb +30 -12
  35. data/lib/steep/services/stats_calculator.rb +0 -1
  36. data/lib/steep/services/type_check_service.rb +15 -12
  37. data/lib/steep/shims/symbol_start_with.rb +18 -0
  38. data/lib/steep/signature/validator.rb +25 -1
  39. data/lib/steep/source.rb +1 -1
  40. data/lib/steep/subtyping/check.rb +0 -3
  41. data/lib/steep/subtyping/constraints.rb +43 -14
  42. data/lib/steep/type_construction.rb +721 -764
  43. data/lib/steep/type_inference/constant_env.rb +0 -2
  44. data/lib/steep/type_inference/context.rb +23 -17
  45. data/lib/steep/type_inference/logic_type_interpreter.rb +210 -117
  46. data/lib/steep/type_inference/method_call.rb +80 -6
  47. data/lib/steep/type_inference/multiple_assignment.rb +189 -0
  48. data/lib/steep/type_inference/send_args.rb +1 -2
  49. data/lib/steep/type_inference/type_env.rb +273 -116
  50. data/lib/steep/type_inference/type_env_builder.rb +138 -0
  51. data/lib/steep/typing.rb +2 -0
  52. data/lib/steep/version.rb +1 -1
  53. data/lib/steep.rb +7 -5
  54. data/rbs_collection.steep.lock.yaml +112 -0
  55. data/rbs_collection.steep.yaml +19 -0
  56. data/sample/sig/conference.rbs +8 -0
  57. data/sig/shims/parser/source/map.rbs +146 -0
  58. data/sig/shims/parser/source/range.rbs +237 -0
  59. data/sig/shims/parser.rbs +17 -0
  60. data/sig/steep/ast/annotation/collection.rbs +75 -0
  61. data/sig/steep/ast/annotation.rbs +126 -0
  62. data/sig/steep/ast/builtin.rbs +69 -0
  63. data/sig/steep/ast/type_params.rbs +11 -0
  64. data/sig/steep/ast/types/any.rbs +29 -0
  65. data/sig/steep/ast/types/boolean.rbs +31 -0
  66. data/sig/steep/ast/types/bot.rbs +29 -0
  67. data/sig/steep/ast/types/class.rbs +29 -0
  68. data/sig/steep/ast/types/factory.rbs +76 -0
  69. data/sig/steep/ast/types/helper.rbs +19 -0
  70. data/sig/steep/ast/types/instance.rbs +29 -0
  71. data/sig/steep/ast/types/intersection.rbs +35 -0
  72. data/sig/steep/ast/types/literal.rbs +33 -0
  73. data/sig/steep/ast/types/logic.rbs +78 -0
  74. data/sig/steep/ast/types/name.rbs +71 -0
  75. data/sig/steep/ast/types/nil.rbs +31 -0
  76. data/sig/steep/ast/types/proc.rbs +46 -0
  77. data/sig/steep/ast/types/record.rbs +38 -0
  78. data/sig/steep/ast/types/self.rbs +29 -0
  79. data/sig/steep/ast/types/top.rbs +29 -0
  80. data/sig/steep/ast/types/tuple.rbs +34 -0
  81. data/sig/steep/ast/types/union.rbs +38 -0
  82. data/sig/steep/ast/types/var.rbs +37 -0
  83. data/sig/steep/ast/types/void.rbs +29 -0
  84. data/sig/steep/ast/types.rbs +37 -0
  85. data/sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs +15 -0
  86. data/sig/steep/diagnostic/helper.rbs +9 -0
  87. data/sig/steep/diagnostic/lsp_formatter.rbs +29 -0
  88. data/sig/steep/diagnostic/ruby.rbs +494 -0
  89. data/sig/steep/diagnostic/signature.rbs +215 -0
  90. data/sig/steep/interface/block.rbs +35 -0
  91. data/sig/steep/interface/function.rbs +253 -0
  92. data/sig/steep/interface/interface.rbs +23 -0
  93. data/sig/steep/interface/method_type.rbs +55 -0
  94. data/sig/steep/interface/substitution.rbs +53 -0
  95. data/sig/steep/interface/type_param.rbs +35 -0
  96. data/sig/steep/method_name.rbs +26 -0
  97. data/sig/steep/module_helper.rbs +7 -0
  98. data/sig/steep/node_helper.rbs +11 -0
  99. data/sig/steep/project/dsl.rbs +94 -0
  100. data/sig/steep/project/options.rbs +15 -0
  101. data/sig/steep/project/pattern.rbs +25 -0
  102. data/sig/steep/project/target.rbs +25 -0
  103. data/sig/steep/project.rbs +19 -0
  104. data/sig/steep/services/completion_provider.rbs +123 -0
  105. data/sig/steep/services/content_change.rbs +35 -0
  106. data/sig/steep/services/file_loader.rbs +13 -0
  107. data/sig/steep/services/goto_service.rbs +45 -0
  108. data/sig/steep/services/hover_provider/rbs.rbs +21 -0
  109. data/sig/steep/services/hover_provider/ruby.rbs +109 -0
  110. data/sig/steep/services/hover_provider/singleton_methods.rbs +11 -0
  111. data/sig/steep/services/path_assignment.rbs +21 -0
  112. data/sig/steep/services/signature_service.rbs +91 -0
  113. data/sig/steep/services/stats_calculator.rbs +17 -0
  114. data/sig/steep/services/type_check_service.rbs +93 -0
  115. data/sig/steep/source.rbs +55 -0
  116. data/sig/steep/subtyping/cache.rbs +17 -0
  117. data/sig/steep/subtyping/check.rbs +93 -0
  118. data/sig/steep/subtyping/constraints.rbs +111 -0
  119. data/sig/steep/subtyping/relation.rbs +51 -0
  120. data/sig/steep/subtyping/result.rbs +157 -0
  121. data/sig/steep/subtyping/variable_variance.rbs +23 -0
  122. data/sig/steep/type_construction.rbs +285 -0
  123. data/sig/steep/type_inference/block_params.rbs +52 -0
  124. data/sig/steep/type_inference/constant_env.rbs +27 -0
  125. data/sig/steep/type_inference/context.rbs +137 -0
  126. data/sig/steep/type_inference/logic_type_interpreter.rbs +72 -0
  127. data/sig/steep/type_inference/method_call.rbs +124 -0
  128. data/sig/steep/type_inference/method_params.rbs +104 -0
  129. data/sig/steep/type_inference/multiple_assignment.rbs +76 -0
  130. data/sig/steep/type_inference/type_env.rbs +158 -0
  131. data/sig/steep/type_inference/type_env_builder.rbs +77 -0
  132. data/sig/steep/typing.rbs +68 -0
  133. data/sig/steep.rbs +31 -0
  134. data/smoke/class/f.rb +1 -0
  135. data/smoke/class/test_expectations.yml +2 -2
  136. data/smoke/diagnostics/test_expectations.yml +4 -2
  137. data/smoke/regression/lambda.rb +3 -0
  138. data/smoke/regression/test_expectations.yml +12 -0
  139. data/steep.gemspec +1 -1
  140. metadata +95 -9
  141. data/lib/steep/subtyping/variable_occurrence.rb +0 -51
  142. data/lib/steep/type_inference/local_variable_type_env.rb +0 -249
  143. data/lib/steep/type_inference/logic.rb +0 -161
@@ -0,0 +1,104 @@
1
+ module Steep
2
+ module TypeInference
3
+ class MethodParams
4
+ class BaseParameter
5
+ attr_reader name: Symbol
6
+
7
+ attr_reader type: untyped
8
+
9
+ attr_reader node: Parser::AST::Node
10
+
11
+ def initialize: (name: Symbol, type: untyped, node: Parser::AST::Node) -> void
12
+
13
+ def optional?: () -> bool
14
+
15
+ def value: () -> Parser::AST::Node
16
+
17
+ def var_type: () -> AST::Types::t
18
+
19
+ def untyped?: () -> bool
20
+
21
+ def ==: (untyped other) -> untyped
22
+
23
+ alias eql? ==
24
+
25
+ def hash: () -> Integer
26
+ end
27
+
28
+ class PositionalParameter < BaseParameter
29
+ end
30
+
31
+ class KeywordParameter < BaseParameter
32
+ end
33
+
34
+ class BaseRestParameter
35
+ attr_reader name: Symbol
36
+
37
+ attr_reader type: untyped
38
+
39
+ attr_reader node: Parser::AST::Node
40
+
41
+ def initialize: (name: Symbol, type: untyped, node: Parser::AST::Node) -> void
42
+
43
+ def ==: (untyped other) -> bool
44
+
45
+ alias eql? ==
46
+
47
+ def hash: () -> Integer
48
+
49
+ def var_type: () -> AST::Types::t
50
+ end
51
+
52
+ class PositionalRestParameter < BaseRestParameter
53
+ def var_type: () -> AST::Types::t
54
+ end
55
+
56
+ class KeywordRestParameter < BaseRestParameter
57
+ def var_type: () -> AST::Types::t
58
+ end
59
+
60
+ class BlockParameter
61
+ attr_reader name: untyped
62
+
63
+ attr_reader type: untyped
64
+
65
+ attr_reader node: untyped
66
+
67
+ def initialize: (name: untyped, type: untyped, node: untyped, optional: untyped) -> void
68
+
69
+ def optional?: () -> (true | false)
70
+
71
+ def var_type: () -> AST::Types::t
72
+
73
+ def ==: (untyped other) -> untyped
74
+
75
+ alias eql? ==
76
+
77
+ def hash: () -> untyped
78
+ end
79
+
80
+ attr_reader args: untyped
81
+
82
+ attr_reader method_type: untyped
83
+
84
+ attr_reader params: untyped
85
+
86
+ attr_reader errors: untyped
87
+
88
+ def initialize: (args: untyped, method_type: untyped) -> void
89
+
90
+ def []: (untyped name) -> untyped
91
+
92
+ def size: () -> Integer
93
+
94
+ def each_param: () { (BaseParameter | BaseRestParameter | BlockParameter) -> void } -> void
95
+ | () -> Enumerator[BaseParameter | BaseRestParameter | BlockParameter, void]
96
+
97
+ def each: () { (Symbol, BaseRestParameter | BaseRestParameter | BlockParameter) -> void } -> void
98
+
99
+ def self.empty: (node: Parser::AST::Node) -> MethodParams
100
+
101
+ def self.build: (node: Parser::AST::Node, method_type: untyped) -> MethodParams
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,76 @@
1
+ module Steep
2
+ module TypeInference
3
+ # This class provides an abstraction for multiple assignments.
4
+ #
5
+ class MultipleAssignment
6
+ type node_type_pair = [Parser::AST::Node, AST::Types::t]
7
+
8
+ # Encapsulate assignments included in one `masgn` node
9
+ #
10
+ # ```ruby
11
+ # a, *b, c = rhs
12
+ # # ^ Leading assignments
13
+ # # ^^ Splat assignment
14
+ # # ^ Trailing assignments
15
+ # ```
16
+ #
17
+ class Assignments
18
+ attr_reader rhs_type: AST::Types::t
19
+
20
+ attr_reader optional: bool
21
+
22
+ # Assignments before `*` assignment
23
+ attr_reader leading_assignments: Array[node_type_pair]
24
+
25
+ # Assignments after `*` assignment
26
+ #
27
+ # Empty if there is no splat assignment.
28
+ #
29
+ attr_reader trailing_assignments: Array[node_type_pair]
30
+
31
+ # Splat assignment if present
32
+ attr_reader splat_assignment: node_type_pair?
33
+
34
+ def initialize: (
35
+ rhs_type: AST::Types::t,
36
+ optional: bool,
37
+ leading_assignments: Array[node_type_pair],
38
+ trailing_assignments: Array[node_type_pair],
39
+ splat_assignment: node_type_pair?
40
+ ) -> void
41
+
42
+ def each: () { (node_type_pair) -> void } -> void
43
+ | () -> Enumerator[node_type_pair, void]
44
+ end
45
+
46
+ def initialize: () -> void
47
+
48
+ # Receives multiple assignment left hand side, right hand side type, and `optional` flag, and returns Assignments object
49
+ #
50
+ # This implements a case analysis on `rhs_type`:
51
+ #
52
+ # 1. If `rhs_type` is tuple, it returns an Assignments object with corresponding assignments
53
+ # 2. If `rhs_type` is an array, it returns an Assignments object with corresponding assignments
54
+ # 3. If `rhs_type` is `untyped`, it returns an Assignments with `untyped` type
55
+ # 4. It returns `nil` otherwise
56
+ #
57
+ def expand: (Parser::AST::Node mlhs, AST::Types::t rhs_type, bool optional) -> Assignments?
58
+
59
+ # Returns a type hint for multiple assignment right hand side
60
+ #
61
+ # It constructs a structure of tuple types, based on the assignment lhs, and variable types.
62
+ #
63
+ def hint_for_mlhs: (Parser::AST::Node mlhs, TypeEnv env) -> AST::Types::t?
64
+
65
+ private
66
+
67
+ def expand_tuple: (Array[Parser::AST::Node] assignments, AST::Types::t rhs_type, Array[AST::Types::t] types, bool optional) -> Assignments
68
+
69
+ def expand_array: (Array[Parser::AST::Node] assignments, AST::Types::Name::Instance rhs_type, bool optional) -> Assignments
70
+
71
+ def expand_any: (Array[Parser::AST::Node] assignments, AST::Types::t rhs_type, AST::Types::t element_type, bool optional) -> Assignments
72
+
73
+ def expand_else: (Array[Parser::AST::Node] assignments, AST::Types::t rhs_type, bool optional) -> Assignments
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,158 @@
1
+ module Steep
2
+ module TypeInference
3
+ # TypeEnv is the one-stop class to manage type of variables.
4
+ #
5
+ # ### Local variables primitive operations
6
+ #
7
+ # * Assigning to a local variable
8
+ # * Adding local variable type enforcement
9
+ # * Refine local variable types
10
+ # * Resetting refinements
11
+ #
12
+ # ### Pure calls primitive operations
13
+ #
14
+ # * Adding pure calls
15
+ # * Removing pure calls
16
+ # * Refine pure call types
17
+ # * Resetting pure call refinements
18
+ #
19
+ # ### Branch operations
20
+ #
21
+ # * Start branching with refinements
22
+ # * Merge branches
23
+ #
24
+ #
25
+ class TypeEnv
26
+ include NodeHelper
27
+
28
+ type local_variable_entry = [AST::Types::t, AST::Types::t?]
29
+
30
+ attr_reader local_variable_types: Hash[Symbol, local_variable_entry]
31
+
32
+ attr_reader pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
33
+
34
+ attr_reader instance_variable_types: Hash[Symbol, AST::Types::t]
35
+
36
+ attr_reader global_types: Hash[Symbol, AST::Types::t]
37
+
38
+ attr_reader constant_types: Hash[RBS::TypeName, AST::Types::t]
39
+
40
+ attr_reader constant_env: ConstantEnv
41
+
42
+ @pure_node_descendants: Hash[Parser::AST::Node, Set[Parser::AST::Node]]
43
+
44
+ def initialize: (
45
+ ConstantEnv,
46
+ ?local_variable_types: Hash[Symbol, local_variable_entry],
47
+ ?instance_variable_types: Hash[Symbol, AST::Types::t],
48
+ ?global_types: Hash[Symbol, AST::Types::t],
49
+ ?constant_types: Hash[RBS::TypeName, AST::Types::t],
50
+ ?pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
51
+ ) -> void
52
+
53
+ def update: (
54
+ ?local_variable_types: Hash[Symbol, local_variable_entry],
55
+ ?instance_variable_types: Hash[Symbol, AST::Types::t],
56
+ ?global_types: Hash[Symbol, AST::Types::t],
57
+ ?constant_types: Hash[RBS::TypeName, AST::Types::t],
58
+ ?pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
59
+ ) -> TypeEnv
60
+
61
+ def merge: (
62
+ ?local_variable_types: Hash[Symbol, local_variable_entry],
63
+ ?instance_variable_types: Hash[Symbol, AST::Types::t],
64
+ ?global_types: Hash[Symbol, AST::Types::t],
65
+ ?constant_types: Hash[RBS::TypeName, AST::Types::t],
66
+ ?pure_method_calls: Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
67
+ ) -> TypeEnv
68
+
69
+ # Returns type of `name`.
70
+ #
71
+ def []: (Symbol name) -> AST::Types::t?
72
+ | (Parser::AST::Node node) -> AST::Types::t?
73
+
74
+ # Tells the environment that local variables are updated.
75
+ # Keeps their enforced types and invalidates related nodes.
76
+ #
77
+ def assign_local_variables: (Hash[Symbol, AST::Types::t]) -> TypeEnv
78
+
79
+ # Tells the environment that the local variable is updated with it's enforced type.
80
+ #
81
+ # Invalidates related nodes.
82
+ #
83
+ def assign_local_variable: (Symbol name, AST::Types::t type, AST::Types::t? enforced_type) -> TypeEnv
84
+
85
+ # Refines types of local variables and pure calls.
86
+ #
87
+ # * Receives types of updated local variables and pure calls.
88
+ # * The local variable types will be
89
+ #
90
+ def refine_types: (?local_variable_types: Hash[Symbol, AST::Types::t], ?pure_call_types: Hash[Parser::AST::Node, AST::Types::t]) -> TypeEnv
91
+
92
+ def enforced_type: (Symbol name) -> AST::Types::t?
93
+
94
+ # Returns type of constant of `const_name`, or `const_name` under `mod_name`.
95
+ #
96
+ # Returns `nil` if no such constant found.
97
+ #
98
+ def constant: (Symbol const_name, bool toplevel) -> ConstantEnv::constant_tuple?
99
+ | (RBS::TypeName mod_name, Symbol const_name) -> ConstantEnv::constant_tuple?
100
+
101
+ def annotated_constant: (RBS::TypeName) -> AST::Types::t?
102
+
103
+ # _Pin_ the local variables if array is given.
104
+ # When `nil` is given, all local variables are _pinned_.
105
+ #
106
+ def pin_local_variables: (Array[Symbol]? names) -> Hash[Symbol, local_variable_entry]
107
+
108
+ # _Unpin_ the local variables if array is given.
109
+ # When `nil` is given, all local variables are _unpinned_.
110
+ #
111
+ def unpin_local_variables: (Array[Symbol]? names) -> TypeEnv
112
+
113
+ def to_s: () -> String
114
+
115
+ # Apply the substitution to the type of local variables.
116
+ #
117
+ def subst: (Interface::Substitution) -> TypeEnv
118
+
119
+ # Returns a `TypeEnv` such that:
120
+ #
121
+ # * All of the given environments are result of the type checking of branches from `self`,
122
+ # * All of the branches meet at one point, with the returned `TypeEnv`
123
+ #
124
+ # See the example below:
125
+ #
126
+ # ```ruby
127
+ # if foo() # The original environment `self` is for after the evaluation of `foo()`
128
+ # a = bar() # One environment `env1` can be given from after the evaluation of `bar()`
129
+ # else
130
+ # b = baz() # Another environment `env2` is from after the evaluation of `baz`
131
+ # end
132
+ #
133
+ # ??? # How is the environment for here is `self.merge(env1, env2)`
134
+ # # The environment has both optional types of `a` and `b`
135
+ # ```
136
+ #
137
+ def join: (*TypeEnv) -> TypeEnv
138
+
139
+ def add_pure_call: (Parser::AST::Node, MethodCall::Typed, AST::Types::t?) -> TypeEnv
140
+
141
+ def replace_pure_call_type: (Parser::AST::Node, AST::Types::t) -> TypeEnv
142
+
143
+ def invalidate_pure_node: (Parser::AST::Node) -> TypeEnv
144
+
145
+ private
146
+
147
+ def pure_node_invalidation: (Enumerable[Parser::AST::Node] invalidated_nodes) -> Hash[Parser::AST::Node, [MethodCall::Typed, AST::Types::t?]]
148
+
149
+ def invalidated_pure_nodes: (Parser::AST::Node) -> Set[Parser::AST::Node]
150
+
151
+ def local_variable_name?: (Symbol) -> bool
152
+
153
+ def instance_variable_name?: (Symbol) -> bool
154
+
155
+ def global_name?: (Symbol) -> bool
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,77 @@
1
+ module Steep
2
+ module TypeInference
3
+ class TypeEnvBuilder
4
+ module Command
5
+ interface _Base
6
+ def call: (TypeEnv) -> TypeEnv
7
+ end
8
+
9
+ class RBSBase
10
+ attr_reader environment: RBS::Environment
11
+
12
+ attr_reader factory: AST::Types::Factory
13
+
14
+ def initialize: (AST::Types::Factory) -> void
15
+ end
16
+
17
+ class AnnotationsBase
18
+ attr_reader annotations: AST::Annotation::Collection
19
+
20
+ def initialize: (AST::Annotation::Collection) -> void
21
+ end
22
+
23
+ # Insert local variable annotations.
24
+ #
25
+ # * When _merge mode_ is on, adds and overwrite local variables.
26
+ # * When _merge mode_ is off, it wipes all existing local variables and adds from annotations.
27
+ #
28
+ class ImportLocalVariableAnnotations < AnnotationsBase
29
+ include _Base
30
+
31
+ attr_reader on_duplicate: (^(Symbol, AST::Types::t, AST::Types::t) -> void)?
32
+
33
+ @merge: bool
34
+
35
+ # Set _merge mode_ `on`.
36
+ def merge!: (?bool) -> self
37
+
38
+ def on_duplicate!: () { (Symbol name, AST::Types::t original, AST::Types::t annotation) -> void } -> self
39
+ end
40
+
41
+ # Insert global variable types into type environment from `RBS::Environment`.
42
+ #
43
+ class ImportGlobalDeclarations < RBSBase
44
+ def merge!: (?bool) -> self
45
+
46
+ @merge: bool
47
+
48
+ include _Base
49
+ end
50
+
51
+ class ImportInstanceVariableAnnotations < AnnotationsBase
52
+ include _Base
53
+ end
54
+
55
+ class ImportInstanceVariableDefinition
56
+ attr_reader definition: RBS::Definition?
57
+
58
+ attr_reader factory: AST::Types::Factory
59
+
60
+ def initialize: (RBS::Definition?, AST::Types::Factory) -> void
61
+
62
+ include _Base
63
+ end
64
+
65
+ class ImportConstantAnnotations < AnnotationsBase
66
+ include _Base
67
+ end
68
+ end
69
+
70
+ attr_reader commands: Array[Command::_Base]
71
+
72
+ def initialize: (*Command::_Base) -> void
73
+
74
+ def build: (TypeEnv) -> TypeEnv
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,68 @@
1
+ module Steep
2
+ class Typing
3
+ class UnknownNodeError < StandardError
4
+ attr_reader op: untyped
5
+
6
+ attr_reader node: untyped
7
+
8
+ def initialize: (untyped op, node: untyped) -> void
9
+ end
10
+
11
+ attr_reader source: Source
12
+
13
+ attr_reader errors: untyped
14
+
15
+ attr_reader typing: untyped
16
+
17
+ attr_reader parent: untyped
18
+
19
+ attr_reader parent_last_update: untyped
20
+
21
+ attr_reader last_update: untyped
22
+
23
+ attr_reader should_update: untyped
24
+
25
+ attr_reader contexts: untyped
26
+
27
+ attr_reader root_context: untyped
28
+
29
+ attr_reader method_calls: untyped
30
+
31
+ attr_reader source_index: untyped
32
+
33
+ def initialize: (source: untyped, root_context: untyped, ?parent: untyped?, ?parent_last_update: untyped, ?contexts: untyped?, ?source_index: untyped?) -> void
34
+
35
+ def add_error: (untyped error) -> untyped
36
+
37
+ def add_typing: (Parser::AST::Node node, AST::Types::t `type`, TypeInference::Context _context) -> untyped
38
+
39
+ def add_call: (untyped node, untyped call) -> untyped
40
+
41
+ def add_context: (Range[Integer] range, context: TypeInference::Context) -> void
42
+
43
+ def has_type?: (untyped node) -> untyped
44
+
45
+ def type_of: (node: Parser::AST::Node) -> AST::Types::t
46
+
47
+ def call_of: (node: untyped) -> untyped
48
+
49
+ def add_context_for_node: (untyped node, context: untyped) -> untyped
50
+
51
+ def block_range: (untyped node) -> ::Range[untyped]
52
+
53
+ def add_context_for_body: (untyped node, context: untyped) -> untyped
54
+
55
+ def context_at: (line: Integer, column: Integer) -> TypeInference::Context
56
+
57
+ def dump: (untyped io) -> untyped
58
+
59
+ def self.summary: (untyped node) -> ::String
60
+
61
+ def new_child: [A] (Range[Integer] range) { (Typing) -> A } -> A
62
+ | (Range[Integer]) -> Typing
63
+
64
+ def each_typing: () { () -> untyped } -> untyped
65
+
66
+ def save!: () -> void
67
+ end
68
+ end
data/sig/steep.rbs ADDED
@@ -0,0 +1,31 @@
1
+ module Steep
2
+ def self.logger: () -> Logger
3
+
4
+ def self.new_logger: (untyped output, untyped prev_level) -> untyped
5
+
6
+ def self.log_output: () -> untyped
7
+
8
+ def self.log_output=: (untyped output) -> untyped
9
+
10
+ def self.measure: (untyped message, ?level: ::Symbol) { () -> untyped } -> untyped
11
+
12
+ def self.log_error: (untyped exn, ?message: ::String) -> untyped
13
+
14
+ class Sampler
15
+ def initialize: () -> void
16
+
17
+ def sample: (untyped message) { () -> untyped } -> untyped
18
+
19
+ def count: () -> untyped
20
+
21
+ def total: () -> untyped
22
+
23
+ def slowests: (untyped num) -> untyped
24
+
25
+ def average: () -> (untyped | 0)
26
+
27
+ def percentile: (untyped p) -> untyped
28
+ end
29
+
30
+ def self.measure2: (untyped message, ?level: ::Symbol) { (untyped) -> untyped } -> untyped
31
+ end
data/smoke/class/f.rb CHANGED
@@ -6,4 +6,5 @@ d = (_ = nil)
6
6
 
7
7
  e = d
8
8
 
9
+ e = _ = nil
9
10
  d = e
@@ -56,10 +56,10 @@
56
56
  diagnostics:
57
57
  - range:
58
58
  start:
59
- line: 9
59
+ line: 10
60
60
  character: 0
61
61
  end:
62
- line: 9
62
+ line: 10
63
63
  character: 5
64
64
  severity: ERROR
65
65
  message: |-
@@ -489,8 +489,10 @@
489
489
  line: 2
490
490
  character: 10
491
491
  severity: ERROR
492
- message: The value given to break will be ignored
493
- code: Ruby::UnexpectedJumpValue
492
+ message: |-
493
+ Cannot break with a value of type `::Integer` because type `nil` is assumed
494
+ ::Integer <: nil
495
+ code: Ruby::BreakTypeMismatch
494
496
  - file: unexpected_keyword.rb
495
497
  diagnostics:
496
498
  - range:
@@ -0,0 +1,3 @@
1
+ module Mod
2
+ ->(){}
3
+ end
@@ -40,6 +40,18 @@
40
40
  | (::Numeric) -> ::Time
41
41
  | (::Time) -> ::Float
42
42
  code: Ruby::UnresolvedOverloading
43
+ - file: lambda.rb
44
+ diagnostics:
45
+ - range:
46
+ start:
47
+ line: 1
48
+ character: 7
49
+ end:
50
+ line: 1
51
+ character: 10
52
+ severity: ERROR
53
+ message: 'Cannot find the declaration of module: `Mod`'
54
+ code: Ruby::UnknownConstant
43
55
  - file: set_divide.rb
44
56
  diagnostics:
45
57
  - range:
data/steep.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.required_ruby_version = '>= 2.6.0'
30
30
 
31
- spec.add_runtime_dependency "parser", ">= 3.0"
31
+ spec.add_runtime_dependency "parser", ">= 3.1"
32
32
  spec.add_runtime_dependency "activesupport", ">= 5.1"
33
33
  spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
34
34
  spec.add_runtime_dependency "listen", "~> 3.0"