steep 0.37.0 → 0.42.0
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 +1 -1
- data/CHANGELOG.md +34 -0
- data/Rakefile +5 -2
- data/bin/output_rebaseline.rb +34 -0
- data/bin/output_test.rb +53 -0
- data/lib/steep.rb +95 -14
- data/lib/steep/ast/types/bot.rb +1 -1
- data/lib/steep/ast/types/class.rb +4 -0
- data/lib/steep/ast/types/factory.rb +10 -0
- data/lib/steep/ast/types/logic.rb +16 -3
- data/lib/steep/ast/types/top.rb +1 -1
- data/lib/steep/cli.rb +31 -7
- data/lib/steep/diagnostic/helper.rb +17 -0
- data/lib/steep/diagnostic/lsp_formatter.rb +16 -0
- data/lib/steep/diagnostic/ruby.rb +619 -0
- data/lib/steep/diagnostic/signature.rb +357 -0
- data/lib/steep/drivers/annotations.rb +19 -28
- data/lib/steep/drivers/check.rb +182 -60
- data/lib/steep/drivers/diagnostic_printer.rb +99 -0
- data/lib/steep/drivers/langserver.rb +3 -8
- data/lib/steep/drivers/print_project.rb +10 -9
- data/lib/steep/drivers/stats.rb +124 -32
- data/lib/steep/drivers/trace_printer.rb +5 -1
- data/lib/steep/drivers/utils/jobs_count.rb +9 -0
- data/lib/steep/drivers/validate.rb +31 -13
- data/lib/steep/drivers/watch.rb +69 -48
- data/lib/steep/drivers/worker.rb +16 -8
- data/lib/steep/expectations.rb +159 -0
- data/lib/steep/index/rbs_index.rb +334 -0
- data/lib/steep/index/signature_symbol_provider.rb +162 -0
- data/lib/steep/index/source_index.rb +100 -0
- data/lib/steep/project.rb +0 -30
- data/lib/steep/project/dsl.rb +5 -3
- data/lib/steep/project/options.rb +4 -4
- data/lib/steep/project/pattern.rb +56 -0
- data/lib/steep/project/target.rb +9 -214
- data/lib/steep/range_extension.rb +29 -0
- data/lib/steep/server/base_worker.rb +43 -7
- data/lib/steep/server/change_buffer.rb +63 -0
- data/lib/steep/server/interaction_worker.rb +73 -56
- data/lib/steep/server/master.rb +245 -109
- data/lib/steep/server/type_check_worker.rb +122 -0
- data/lib/steep/server/worker_process.rb +17 -15
- data/lib/steep/{project → services}/completion_provider.rb +3 -3
- data/lib/steep/services/content_change.rb +61 -0
- data/lib/steep/services/file_loader.rb +48 -0
- data/lib/steep/{project → services}/hover_content.rb +14 -16
- data/lib/steep/services/path_assignment.rb +29 -0
- data/lib/steep/services/signature_service.rb +369 -0
- data/lib/steep/services/stats_calculator.rb +69 -0
- data/lib/steep/services/type_check_service.rb +342 -0
- data/lib/steep/signature/validator.rb +174 -32
- data/lib/steep/subtyping/check.rb +248 -47
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/type_construction.rb +565 -295
- data/lib/steep/type_inference/constant_env.rb +5 -1
- data/lib/steep/type_inference/local_variable_type_env.rb +26 -12
- data/lib/steep/type_inference/logic_type_interpreter.rb +99 -26
- data/lib/steep/type_inference/type_env.rb +43 -17
- data/lib/steep/typing.rb +8 -2
- data/lib/steep/version.rb +1 -1
- data/smoke/alias/a.rb +0 -3
- data/smoke/alias/b.rb +0 -1
- data/smoke/alias/c.rb +0 -2
- data/smoke/alias/test_expectations.yml +96 -0
- data/smoke/and/a.rb +0 -3
- data/smoke/and/test_expectations.yml +31 -0
- data/smoke/array/a.rb +0 -3
- data/smoke/array/b.rb +0 -2
- data/smoke/array/c.rb +0 -1
- data/smoke/array/test_expectations.yml +103 -0
- data/smoke/block/a.rb +0 -2
- data/smoke/block/b.rb +0 -2
- data/smoke/block/d.rb +0 -4
- data/smoke/block/test_expectations.yml +125 -0
- data/smoke/case/a.rb +0 -3
- data/smoke/case/test_expectations.yml +47 -0
- data/smoke/class/a.rb +0 -3
- data/smoke/class/c.rb +0 -1
- data/smoke/class/f.rb +0 -1
- data/smoke/class/g.rb +0 -2
- data/smoke/class/i.rb +0 -2
- data/smoke/class/test_expectations.yml +120 -0
- data/smoke/const/a.rb +0 -3
- data/smoke/const/b.rb +7 -0
- data/smoke/const/b.rbs +5 -0
- data/smoke/const/test_expectations.yml +139 -0
- data/smoke/diagnostics-rbs-duplicated/Steepfile +5 -0
- data/smoke/diagnostics-rbs-duplicated/a.rbs +5 -0
- data/smoke/diagnostics-rbs-duplicated/test_expectations.yml +13 -0
- data/smoke/diagnostics-rbs/Steepfile +8 -0
- data/smoke/diagnostics-rbs/duplicated-method-definition.rbs +20 -0
- data/smoke/diagnostics-rbs/generic-parameter-mismatch.rbs +7 -0
- data/smoke/diagnostics-rbs/invalid-method-overload.rbs +3 -0
- data/smoke/diagnostics-rbs/invalid-type-application.rbs +7 -0
- data/smoke/diagnostics-rbs/invalid_variance_annotation.rbs +3 -0
- data/smoke/diagnostics-rbs/recursive-alias.rbs +5 -0
- data/smoke/diagnostics-rbs/recursive-class.rbs +8 -0
- data/smoke/diagnostics-rbs/superclass-mismatch.rbs +7 -0
- data/smoke/diagnostics-rbs/test_expectations.yml +231 -0
- data/smoke/diagnostics-rbs/unknown-method-alias.rbs +3 -0
- data/smoke/diagnostics-rbs/unknown-type-name-2.rbs +5 -0
- data/smoke/diagnostics-rbs/unknown-type-name.rbs +13 -0
- data/smoke/diagnostics/Steepfile +5 -0
- data/smoke/diagnostics/a.rbs +26 -0
- data/smoke/diagnostics/argument_type_mismatch.rb +1 -0
- data/smoke/diagnostics/block_body_type_mismatch.rb +1 -0
- data/smoke/diagnostics/block_type_mismatch.rb +3 -0
- data/smoke/diagnostics/break_type_mismatch.rb +1 -0
- data/smoke/diagnostics/else_on_exhaustive_case.rb +12 -0
- data/smoke/diagnostics/incompatible_annotation.rb +6 -0
- data/smoke/diagnostics/incompatible_argument.rb +1 -0
- data/smoke/diagnostics/incompatible_assignment.rb +8 -0
- data/smoke/diagnostics/method_arity_mismatch.rb +11 -0
- data/smoke/diagnostics/method_body_type_mismatch.rb +6 -0
- data/smoke/diagnostics/method_definition_missing.rb +2 -0
- data/smoke/diagnostics/method_return_type_annotation_mismatch.rb +7 -0
- data/smoke/diagnostics/missing_keyword.rb +1 -0
- data/smoke/diagnostics/no_method.rb +1 -0
- data/smoke/diagnostics/required_block_missing.rb +1 -0
- data/smoke/diagnostics/return_type_mismatch.rb +6 -0
- data/smoke/diagnostics/test_expectations.yml +477 -0
- data/smoke/diagnostics/unexpected_block_given.rb +1 -0
- data/smoke/diagnostics/unexpected_dynamic_method.rb +3 -0
- data/smoke/diagnostics/unexpected_jump.rb +4 -0
- data/smoke/diagnostics/unexpected_jump_value.rb +3 -0
- data/smoke/diagnostics/unexpected_keyword.rb +1 -0
- data/smoke/diagnostics/unexpected_splat.rb +1 -0
- data/smoke/diagnostics/unexpected_yield.rb +6 -0
- data/smoke/diagnostics/unknown_constant_assigned.rb +7 -0
- data/smoke/diagnostics/unresolved_overloading.rb +1 -0
- data/smoke/diagnostics/unsatisfiable_constraint.rb +7 -0
- data/smoke/diagnostics/unsupported_syntax.rb +2 -0
- data/smoke/dstr/a.rb +0 -1
- data/smoke/dstr/test_expectations.yml +13 -0
- data/smoke/ensure/a.rb +0 -4
- data/smoke/ensure/test_expectations.yml +62 -0
- data/smoke/enumerator/a.rb +0 -6
- data/smoke/enumerator/b.rb +0 -3
- data/smoke/enumerator/test_expectations.yml +135 -0
- data/smoke/extension/a.rb +0 -1
- data/smoke/extension/b.rb +0 -2
- data/smoke/extension/c.rb +0 -1
- data/smoke/extension/f.rb +2 -0
- data/smoke/extension/f.rbs +3 -0
- data/smoke/extension/test_expectations.yml +73 -0
- data/smoke/hash/b.rb +0 -1
- data/smoke/hash/c.rb +0 -3
- data/smoke/hash/d.rb +0 -1
- data/smoke/hash/e.rb +0 -1
- data/smoke/hash/test_expectations.yml +81 -0
- data/smoke/hello/hello.rb +0 -2
- data/smoke/hello/test_expectations.yml +25 -0
- data/smoke/if/a.rb +0 -2
- data/smoke/if/test_expectations.yml +34 -0
- data/smoke/implements/a.rb +0 -2
- data/smoke/implements/test_expectations.yml +23 -0
- data/smoke/initialize/test_expectations.yml +1 -0
- data/smoke/integer/a.rb +0 -7
- data/smoke/integer/test_expectations.yml +101 -0
- data/smoke/interface/a.rb +0 -2
- data/smoke/interface/test_expectations.yml +23 -0
- data/smoke/kwbegin/a.rb +0 -1
- data/smoke/kwbegin/test_expectations.yml +17 -0
- data/smoke/lambda/a.rb +1 -4
- data/smoke/lambda/test_expectations.yml +39 -0
- data/smoke/literal/a.rb +0 -5
- data/smoke/literal/b.rb +0 -2
- data/smoke/literal/test_expectations.yml +106 -0
- data/smoke/map/test_expectations.yml +1 -0
- data/smoke/method/a.rb +0 -5
- data/smoke/method/b.rb +0 -1
- data/smoke/method/test_expectations.yml +90 -0
- data/smoke/module/a.rb +0 -2
- data/smoke/module/b.rb +0 -2
- data/smoke/module/c.rb +0 -1
- data/smoke/module/d.rb +0 -1
- data/smoke/module/f.rb +0 -2
- data/smoke/module/test_expectations.yml +75 -0
- data/smoke/regexp/a.rb +0 -38
- data/smoke/regexp/b.rb +0 -26
- data/smoke/regexp/test_expectations.yml +615 -0
- data/smoke/regression/set_divide.rb +0 -4
- data/smoke/regression/test_expectations.yml +43 -0
- data/smoke/rescue/a.rb +0 -5
- data/smoke/rescue/test_expectations.yml +79 -0
- data/smoke/self/a.rb +0 -2
- data/smoke/self/test_expectations.yml +23 -0
- data/smoke/skip/skip.rb +0 -2
- data/smoke/skip/test_expectations.yml +23 -0
- data/smoke/stdout/test_expectations.yml +1 -0
- data/smoke/super/a.rb +0 -4
- data/smoke/super/test_expectations.yml +79 -0
- data/smoke/toplevel/a.rb +0 -1
- data/smoke/toplevel/test_expectations.yml +15 -0
- data/smoke/tsort/Steepfile +2 -0
- data/smoke/tsort/a.rb +0 -3
- data/smoke/tsort/test_expectations.yml +63 -0
- data/smoke/type_case/a.rb +0 -4
- data/smoke/type_case/test_expectations.yml +48 -0
- data/smoke/unexpected/Steepfile +5 -0
- data/smoke/unexpected/test_expectations.yml +25 -0
- data/smoke/unexpected/unexpected.rb +1 -0
- data/smoke/unexpected/unexpected.rbs +3 -0
- data/smoke/yield/a.rb +0 -3
- data/smoke/yield/b.rb +6 -0
- data/smoke/yield/test_expectations.yml +68 -0
- data/steep.gemspec +4 -3
- metadata +144 -29
- data/bin/smoke_runner.rb +0 -139
- data/lib/steep/drivers/signature_error_printer.rb +0 -25
- data/lib/steep/errors.rb +0 -565
- data/lib/steep/project/file_loader.rb +0 -68
- data/lib/steep/project/signature_file.rb +0 -33
- data/lib/steep/project/source_file.rb +0 -129
- data/lib/steep/server/code_worker.rb +0 -137
- data/lib/steep/server/signature_worker.rb +0 -152
- data/lib/steep/server/utils.rb +0 -69
- data/lib/steep/signature/errors.rb +0 -82
- data/lib/steep/type_assignability.rb +0 -367
@@ -0,0 +1,20 @@
|
|
1
|
+
class DuplicatedMethodDefinitionError
|
2
|
+
def foo: () -> void
|
3
|
+
def foo: () -> Integer
|
4
|
+
|
5
|
+
interface _Hello
|
6
|
+
def f: () -> void
|
7
|
+
|
8
|
+
def f: () -> void
|
9
|
+
end
|
10
|
+
|
11
|
+
interface _A
|
12
|
+
def g: () -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
class A
|
16
|
+
include _A
|
17
|
+
|
18
|
+
def g: () -> String
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
---
|
2
|
+
- file: duplicated-method-definition.rbs
|
3
|
+
diagnostics:
|
4
|
+
- range:
|
5
|
+
start:
|
6
|
+
line: 2
|
7
|
+
character: 2
|
8
|
+
end:
|
9
|
+
line: 2
|
10
|
+
character: 21
|
11
|
+
severity: ERROR
|
12
|
+
message: Non-overloading method definition of `foo` in `::DuplicatedMethodDefinitionError`
|
13
|
+
cannot be duplicated
|
14
|
+
code: RBS::DuplicatedMethodDefinition
|
15
|
+
- range:
|
16
|
+
start:
|
17
|
+
line: 6
|
18
|
+
character: 4
|
19
|
+
end:
|
20
|
+
line: 6
|
21
|
+
character: 21
|
22
|
+
severity: ERROR
|
23
|
+
message: Non-overloading method definition of `f` in `::DuplicatedMethodDefinitionError::_Hello`
|
24
|
+
cannot be duplicated
|
25
|
+
code: RBS::DuplicatedMethodDefinition
|
26
|
+
- range:
|
27
|
+
start:
|
28
|
+
line: 18
|
29
|
+
character: 4
|
30
|
+
end:
|
31
|
+
line: 18
|
32
|
+
character: 23
|
33
|
+
severity: ERROR
|
34
|
+
message: Non-overloading method definition of `g` in `::DuplicatedMethodDefinitionError::A`
|
35
|
+
cannot be duplicated
|
36
|
+
code: RBS::DuplicatedMethodDefinition
|
37
|
+
- file: generic-parameter-mismatch.rbs
|
38
|
+
diagnostics:
|
39
|
+
- range:
|
40
|
+
start:
|
41
|
+
line: 5
|
42
|
+
character: 2
|
43
|
+
end:
|
44
|
+
line: 6
|
45
|
+
character: 5
|
46
|
+
severity: ERROR
|
47
|
+
message: Different generic parameters are specified across definitions of `::GenericParameterMismatchError::Foo`
|
48
|
+
code: RBS::GenericParameterMismatch
|
49
|
+
- file: invalid-method-overload.rbs
|
50
|
+
diagnostics:
|
51
|
+
- range:
|
52
|
+
start:
|
53
|
+
line: 2
|
54
|
+
character: 2
|
55
|
+
end:
|
56
|
+
line: 2
|
57
|
+
character: 27
|
58
|
+
severity: ERROR
|
59
|
+
message: Cannot find a non-overloading definition of `foo` in `::InvalidMethodOverload`
|
60
|
+
code: RBS::InvalidMethodOverload
|
61
|
+
- file: invalid-type-application.rbs
|
62
|
+
diagnostics:
|
63
|
+
- range:
|
64
|
+
start:
|
65
|
+
line: 2
|
66
|
+
character: 13
|
67
|
+
end:
|
68
|
+
line: 2
|
69
|
+
character: 23
|
70
|
+
severity: ERROR
|
71
|
+
message: Type `::Integer` is not generic but used as a generic type with 1 arguments
|
72
|
+
code: RBS::InvalidTypeApplication
|
73
|
+
- range:
|
74
|
+
start:
|
75
|
+
line: 4
|
76
|
+
character: 13
|
77
|
+
end:
|
78
|
+
line: 4
|
79
|
+
character: 24
|
80
|
+
severity: ERROR
|
81
|
+
message: Type `::Array` expects 1 arguments, but 2 arguments are given
|
82
|
+
code: RBS::InvalidTypeApplication
|
83
|
+
- range:
|
84
|
+
start:
|
85
|
+
line: 6
|
86
|
+
character: 13
|
87
|
+
end:
|
88
|
+
line: 6
|
89
|
+
character: 17
|
90
|
+
severity: ERROR
|
91
|
+
message: Type `::Hash` is generic but used as a non generic type
|
92
|
+
code: RBS::InvalidTypeApplication
|
93
|
+
- file: invalid_variance_annotation.rbs
|
94
|
+
diagnostics:
|
95
|
+
- range:
|
96
|
+
start:
|
97
|
+
line: 2
|
98
|
+
character: 11
|
99
|
+
end:
|
100
|
+
line: 2
|
101
|
+
character: 22
|
102
|
+
severity: ERROR
|
103
|
+
message: The variance of type parameter `A` is covariant, but used in incompatible
|
104
|
+
position here
|
105
|
+
code: RBS::InvalidVarianceAnnotation
|
106
|
+
- file: recursive-alias.rbs
|
107
|
+
diagnostics:
|
108
|
+
- range:
|
109
|
+
start:
|
110
|
+
line: 2
|
111
|
+
character: 2
|
112
|
+
end:
|
113
|
+
line: 2
|
114
|
+
character: 15
|
115
|
+
severity: ERROR
|
116
|
+
message: 'Circular method alias is detected in `::RecursiveAlias`: foo -> bar
|
117
|
+
-> baz'
|
118
|
+
code: RBS::RecursiveAlias
|
119
|
+
- file: recursive-class.rbs
|
120
|
+
diagnostics:
|
121
|
+
- range:
|
122
|
+
start:
|
123
|
+
line: 1
|
124
|
+
character: 0
|
125
|
+
end:
|
126
|
+
line: 2
|
127
|
+
character: 3
|
128
|
+
severity: ERROR
|
129
|
+
message: 'Circular inheritance/mix-in is detected: ::Foo <: ::Bar <: ::Baz <:
|
130
|
+
::Foo'
|
131
|
+
code: RBS::RecursiveAncestor
|
132
|
+
- range:
|
133
|
+
start:
|
134
|
+
line: 4
|
135
|
+
character: 0
|
136
|
+
end:
|
137
|
+
line: 5
|
138
|
+
character: 3
|
139
|
+
severity: ERROR
|
140
|
+
message: 'Circular inheritance/mix-in is detected: ::Bar <: ::Baz <: ::Foo <:
|
141
|
+
::Bar'
|
142
|
+
code: RBS::RecursiveAncestor
|
143
|
+
- range:
|
144
|
+
start:
|
145
|
+
line: 7
|
146
|
+
character: 0
|
147
|
+
end:
|
148
|
+
line: 8
|
149
|
+
character: 3
|
150
|
+
severity: ERROR
|
151
|
+
message: 'Circular inheritance/mix-in is detected: ::Baz <: ::Foo <: ::Bar <:
|
152
|
+
::Baz'
|
153
|
+
code: RBS::RecursiveAncestor
|
154
|
+
- file: superclass-mismatch.rbs
|
155
|
+
diagnostics:
|
156
|
+
- range:
|
157
|
+
start:
|
158
|
+
line: 2
|
159
|
+
character: 2
|
160
|
+
end:
|
161
|
+
line: 3
|
162
|
+
character: 5
|
163
|
+
severity: ERROR
|
164
|
+
message: Different superclasses are specified for `::SuperclassMismatch::Foo`
|
165
|
+
code: RBS::SuperclassMismatch
|
166
|
+
- file: unknown-method-alias.rbs
|
167
|
+
diagnostics:
|
168
|
+
- range:
|
169
|
+
start:
|
170
|
+
line: 2
|
171
|
+
character: 2
|
172
|
+
end:
|
173
|
+
line: 2
|
174
|
+
character: 15
|
175
|
+
severity: ERROR
|
176
|
+
message: Cannot find the original method `bar` in `::UnknownMethodAlias`
|
177
|
+
code: RBS::UnknownMethodAlias
|
178
|
+
- file: unknown-type-name-2.rbs
|
179
|
+
diagnostics:
|
180
|
+
- range:
|
181
|
+
start:
|
182
|
+
line: 2
|
183
|
+
character: 13
|
184
|
+
end:
|
185
|
+
line: 2
|
186
|
+
character: 16
|
187
|
+
severity: ERROR
|
188
|
+
message: Cannot find type `::bar`
|
189
|
+
code: RBS::UnknownTypeName
|
190
|
+
- range:
|
191
|
+
start:
|
192
|
+
line: 4
|
193
|
+
character: 9
|
194
|
+
end:
|
195
|
+
line: 4
|
196
|
+
character: 14
|
197
|
+
severity: ERROR
|
198
|
+
message: Cannot find type `::World`
|
199
|
+
code: RBS::UnknownTypeName
|
200
|
+
- file: unknown-type-name.rbs
|
201
|
+
diagnostics:
|
202
|
+
- range:
|
203
|
+
start:
|
204
|
+
line: 6
|
205
|
+
character: 2
|
206
|
+
end:
|
207
|
+
line: 6
|
208
|
+
character: 15
|
209
|
+
severity: ERROR
|
210
|
+
message: Cannot find type `World`
|
211
|
+
code: RBS::UnknownTypeName
|
212
|
+
- range:
|
213
|
+
start:
|
214
|
+
line: 8
|
215
|
+
character: 2
|
216
|
+
end:
|
217
|
+
line: 9
|
218
|
+
character: 5
|
219
|
+
severity: ERROR
|
220
|
+
message: Cannot find type `ABC`
|
221
|
+
code: RBS::UnknownTypeName
|
222
|
+
- range:
|
223
|
+
start:
|
224
|
+
line: 11
|
225
|
+
character: 15
|
226
|
+
end:
|
227
|
+
line: 11
|
228
|
+
character: 18
|
229
|
+
severity: ERROR
|
230
|
+
message: Cannot find type `ZZZ`
|
231
|
+
code: RBS::UnknownTypeName
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class BlockBodyTypeMismatch
|
2
|
+
def foo: () { () -> Integer } -> void
|
3
|
+
end
|
4
|
+
|
5
|
+
class MethodDefinitionMissing
|
6
|
+
def foo: () -> void
|
7
|
+
end
|
8
|
+
|
9
|
+
class UnexpectedDynamicMethod
|
10
|
+
def bar: () -> void
|
11
|
+
end
|
12
|
+
|
13
|
+
class UnknownConstantAssigned
|
14
|
+
end
|
15
|
+
|
16
|
+
class UnsatisfiableConstraint
|
17
|
+
def foo: [A, B] (A) { (A) -> void } -> B
|
18
|
+
end
|
19
|
+
|
20
|
+
class UnexpectedKeyword
|
21
|
+
def foo: (foo: Integer) -> void
|
22
|
+
end
|
23
|
+
|
24
|
+
class MissingKeyword
|
25
|
+
def foo: (?String, foo: Integer, ?bar: Symbol) -> void
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
[123].at("")
|
@@ -0,0 +1 @@
|
|
1
|
+
BlockBodyTypeMismatch.new.foo { "" }
|
@@ -0,0 +1 @@
|
|
1
|
+
123.tap { break "" }
|
@@ -0,0 +1 @@
|
|
1
|
+
[123].at(1,2,3)
|