steep 0.40.0 → 0.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/Gemfile +1 -0
  4. data/bin/output_rebaseline.rb +15 -30
  5. data/bin/output_test.rb +23 -57
  6. data/lib/steep.rb +89 -15
  7. data/lib/steep/annotation_parser.rb +10 -2
  8. data/lib/steep/ast/types/class.rb +4 -0
  9. data/lib/steep/cli.rb +31 -6
  10. data/lib/steep/diagnostic/ruby.rb +13 -8
  11. data/lib/steep/diagnostic/signature.rb +152 -2
  12. data/lib/steep/drivers/annotations.rb +18 -36
  13. data/lib/steep/drivers/check.rb +140 -31
  14. data/lib/steep/drivers/diagnostic_printer.rb +20 -11
  15. data/lib/steep/drivers/langserver.rb +4 -8
  16. data/lib/steep/drivers/print_project.rb +10 -9
  17. data/lib/steep/drivers/stats.rb +135 -119
  18. data/lib/steep/drivers/utils/driver_helper.rb +35 -0
  19. data/lib/steep/drivers/utils/jobs_count.rb +9 -0
  20. data/lib/steep/drivers/validate.rb +29 -18
  21. data/lib/steep/drivers/watch.rb +55 -49
  22. data/lib/steep/drivers/worker.rb +11 -8
  23. data/lib/steep/expectations.rb +159 -0
  24. data/lib/steep/index/signature_symbol_provider.rb +23 -1
  25. data/lib/steep/index/source_index.rb +55 -5
  26. data/lib/steep/interface/block.rb +4 -0
  27. data/lib/steep/project.rb +0 -30
  28. data/lib/steep/project/dsl.rb +5 -3
  29. data/lib/steep/project/pattern.rb +56 -0
  30. data/lib/steep/project/target.rb +11 -227
  31. data/lib/steep/server/base_worker.rb +1 -3
  32. data/lib/steep/server/change_buffer.rb +63 -0
  33. data/lib/steep/server/interaction_worker.rb +72 -57
  34. data/lib/steep/server/master.rb +652 -234
  35. data/lib/steep/server/type_check_worker.rb +304 -0
  36. data/lib/steep/server/worker_process.rb +16 -11
  37. data/lib/steep/{project → services}/completion_provider.rb +5 -5
  38. data/lib/steep/services/content_change.rb +61 -0
  39. data/lib/steep/services/file_loader.rb +48 -0
  40. data/lib/steep/services/goto_service.rb +321 -0
  41. data/lib/steep/{project → services}/hover_content.rb +19 -20
  42. data/lib/steep/services/path_assignment.rb +27 -0
  43. data/lib/steep/services/signature_service.rb +403 -0
  44. data/lib/steep/services/stats_calculator.rb +69 -0
  45. data/lib/steep/services/type_check_service.rb +413 -0
  46. data/lib/steep/signature/validator.rb +187 -85
  47. data/lib/steep/source.rb +21 -18
  48. data/lib/steep/subtyping/check.rb +246 -45
  49. data/lib/steep/subtyping/constraints.rb +4 -4
  50. data/lib/steep/type_construction.rb +428 -193
  51. data/lib/steep/type_inference/block_params.rb +1 -1
  52. data/lib/steep/type_inference/context.rb +22 -0
  53. data/lib/steep/type_inference/local_variable_type_env.rb +26 -12
  54. data/lib/steep/type_inference/logic.rb +1 -1
  55. data/lib/steep/type_inference/logic_type_interpreter.rb +4 -4
  56. data/lib/steep/type_inference/type_env.rb +43 -17
  57. data/lib/steep/version.rb +1 -1
  58. data/smoke/alias/test_expectations.yml +96 -0
  59. data/smoke/and/test_expectations.yml +31 -0
  60. data/smoke/array/test_expectations.yml +103 -0
  61. data/smoke/block/test_expectations.yml +125 -0
  62. data/smoke/case/test_expectations.yml +47 -0
  63. data/smoke/class/test_expectations.yml +120 -0
  64. data/smoke/const/test_expectations.yml +129 -0
  65. data/smoke/diagnostics-rbs-duplicated/test_expectations.yml +13 -0
  66. data/smoke/diagnostics-rbs/Steepfile +7 -4
  67. data/smoke/diagnostics-rbs/test_expectations.yml +231 -0
  68. data/smoke/diagnostics-rbs/unknown-type-name-2.rbs +5 -0
  69. data/smoke/{broken → diagnostics-ruby-unsat}/Steepfile +0 -0
  70. data/smoke/diagnostics-ruby-unsat/a.rbs +3 -0
  71. data/smoke/diagnostics-ruby-unsat/test_expectations.yml +27 -0
  72. data/smoke/{diagnostics → diagnostics-ruby-unsat}/unsatisfiable_constraint.rb +0 -1
  73. data/smoke/diagnostics/a.rbs +0 -4
  74. data/smoke/diagnostics/test_expectations.yml +451 -0
  75. data/smoke/dstr/test_expectations.yml +13 -0
  76. data/smoke/ensure/test_expectations.yml +62 -0
  77. data/smoke/enumerator/test_expectations.yml +135 -0
  78. data/smoke/extension/f.rb +2 -0
  79. data/smoke/extension/f.rbs +3 -0
  80. data/smoke/extension/test_expectations.yml +73 -0
  81. data/smoke/hash/test_expectations.yml +81 -0
  82. data/smoke/hello/test_expectations.yml +25 -0
  83. data/smoke/if/test_expectations.yml +34 -0
  84. data/smoke/implements/b.rb +13 -0
  85. data/smoke/implements/b.rbs +12 -0
  86. data/smoke/implements/test_expectations.yml +23 -0
  87. data/smoke/initialize/test_expectations.yml +1 -0
  88. data/smoke/integer/test_expectations.yml +101 -0
  89. data/smoke/interface/test_expectations.yml +23 -0
  90. data/smoke/kwbegin/test_expectations.yml +17 -0
  91. data/smoke/lambda/test_expectations.yml +39 -0
  92. data/smoke/literal/test_expectations.yml +106 -0
  93. data/smoke/map/test_expectations.yml +1 -0
  94. data/smoke/method/test_expectations.yml +90 -0
  95. data/smoke/module/test_expectations.yml +75 -0
  96. data/smoke/regexp/test_expectations.yml +615 -0
  97. data/smoke/regression/issue_328.rb +1 -0
  98. data/smoke/regression/issue_328.rbs +0 -0
  99. data/smoke/regression/issue_332.rb +11 -0
  100. data/smoke/regression/issue_332.rbs +19 -0
  101. data/smoke/regression/issue_372.rb +8 -0
  102. data/smoke/regression/issue_372.rbs +4 -0
  103. data/smoke/regression/masgn.rb +4 -0
  104. data/smoke/regression/test_expectations.yml +60 -0
  105. data/smoke/regression/thread.rb +7 -0
  106. data/smoke/rescue/test_expectations.yml +79 -0
  107. data/smoke/self/test_expectations.yml +23 -0
  108. data/smoke/skip/test_expectations.yml +23 -0
  109. data/smoke/stdout/test_expectations.yml +1 -0
  110. data/smoke/super/test_expectations.yml +69 -0
  111. data/smoke/toplevel/test_expectations.yml +15 -0
  112. data/smoke/tsort/Steepfile +2 -0
  113. data/smoke/tsort/test_expectations.yml +63 -0
  114. data/smoke/type_case/test_expectations.yml +48 -0
  115. data/smoke/unexpected/Steepfile +5 -0
  116. data/smoke/unexpected/test_expectations.yml +25 -0
  117. data/smoke/unexpected/unexpected.rb +1 -0
  118. data/smoke/unexpected/unexpected.rbs +3 -0
  119. data/smoke/yield/test_expectations.yml +68 -0
  120. data/steep.gemspec +4 -3
  121. metadata +127 -80
  122. data/lib/steep/project/file_loader.rb +0 -68
  123. data/lib/steep/project/signature_file.rb +0 -39
  124. data/lib/steep/project/source_file.rb +0 -129
  125. data/lib/steep/project/stats_calculator.rb +0 -80
  126. data/lib/steep/server/code_worker.rb +0 -150
  127. data/lib/steep/server/signature_worker.rb +0 -157
  128. data/lib/steep/server/utils.rb +0 -69
  129. data/smoke/alias/test.yaml +0 -73
  130. data/smoke/and/test.yaml +0 -24
  131. data/smoke/array/test.yaml +0 -80
  132. data/smoke/block/test.yaml +0 -96
  133. data/smoke/broken/broken.rb +0 -0
  134. data/smoke/broken/broken.rbs +0 -0
  135. data/smoke/broken/test.yaml +0 -6
  136. data/smoke/case/test.yaml +0 -36
  137. data/smoke/class/test.yaml +0 -89
  138. data/smoke/const/test.yaml +0 -96
  139. data/smoke/diagnostics-rbs-duplicated/test.yaml +0 -10
  140. data/smoke/diagnostics-rbs/test.yaml +0 -142
  141. data/smoke/diagnostics/test.yaml +0 -333
  142. data/smoke/dstr/test.yaml +0 -10
  143. data/smoke/ensure/test.yaml +0 -47
  144. data/smoke/enumerator/test.yaml +0 -100
  145. data/smoke/extension/test.yaml +0 -50
  146. data/smoke/hash/test.yaml +0 -62
  147. data/smoke/hello/test.yaml +0 -18
  148. data/smoke/if/test.yaml +0 -27
  149. data/smoke/implements/test.yaml +0 -16
  150. data/smoke/initialize/test.yaml +0 -4
  151. data/smoke/integer/test.yaml +0 -66
  152. data/smoke/interface/test.yaml +0 -16
  153. data/smoke/kwbegin/test.yaml +0 -14
  154. data/smoke/lambda/test.yaml +0 -28
  155. data/smoke/literal/test.yaml +0 -79
  156. data/smoke/map/test.yaml +0 -4
  157. data/smoke/method/test.yaml +0 -71
  158. data/smoke/module/test.yaml +0 -51
  159. data/smoke/regexp/test.yaml +0 -372
  160. data/smoke/regression/test.yaml +0 -38
  161. data/smoke/rescue/test.yaml +0 -60
  162. data/smoke/self/test.yaml +0 -16
  163. data/smoke/skip/test.yaml +0 -16
  164. data/smoke/stdout/test.yaml +0 -4
  165. data/smoke/super/test.yaml +0 -52
  166. data/smoke/toplevel/test.yaml +0 -12
  167. data/smoke/tsort/test.yaml +0 -32
  168. data/smoke/type_case/test.yaml +0 -33
  169. data/smoke/yield/test.yaml +0 -49
@@ -1,38 +0,0 @@
1
- ---
2
- test:
3
- array.rb:
4
- diagnostics: []
5
- fun.rb:
6
- diagnostics: []
7
- hash.rb:
8
- diagnostics: []
9
- poly_new.rb:
10
- diagnostics: []
11
- range.rb:
12
- diagnostics: []
13
- set_divide.rb:
14
- diagnostics:
15
- - |
16
- set_divide.rb:2:2: [error] Type `::Set[::String]` does not have method `ffffffff`
17
- │ Diagnostic ID: Ruby::NoMethod
18
-
19
- └ d.ffffffff
20
- ~~~~~~~~
21
- - |
22
- set_divide.rb:5:4: [error] Type `::String` does not have method `ggggg`
23
- │ Diagnostic ID: Ruby::NoMethod
24
-
25
- └ x.ggggg
26
- ~~~~~
27
- - |
28
- set_divide.rb:7:4: [error] Type `::String` does not have method `ggggg`
29
- │ Diagnostic ID: Ruby::NoMethod
30
-
31
- └ y.ggggg
32
- ~~~~~
33
- - |
34
- set_divide.rb:11:4: [error] Type `::String` does not have method `ggggg`
35
- │ Diagnostic ID: Ruby::NoMethod
36
-
37
- └ x.ggggg
38
- ~~~~~
@@ -1,60 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:3:0: [error] Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::Integer`
7
- │ (::String | ::Integer) <: ::Integer
8
- │ ::String <: ::Integer
9
- │ ::Object <: ::Integer
10
- │ ::BasicObject <: ::Integer
11
-
12
- │ Diagnostic ID: Ruby::IncompatibleAssignment
13
-
14
- └ a = begin
15
- ~~~~~~~~~
16
- - |
17
- a.rb:11:0: [error] Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::Integer`
18
- │ (::String | ::Integer) <: ::Integer
19
- │ ::String <: ::Integer
20
- │ ::Object <: ::Integer
21
- │ ::BasicObject <: ::Integer
22
-
23
- │ Diagnostic ID: Ruby::IncompatibleAssignment
24
-
25
- └ b = 'foo' rescue 1
26
- ~~~~~~~~~~~~~~~~~~
27
- - |
28
- a.rb:15:0: [error] Cannot assign a value of type `(::String | ::Symbol | ::Integer)` to a variable of type `::Integer`
29
- │ (::String | ::Symbol | ::Integer) <: ::Integer
30
- │ ::String <: ::Integer
31
- │ ::Object <: ::Integer
32
- │ ::BasicObject <: ::Integer
33
-
34
- │ Diagnostic ID: Ruby::IncompatibleAssignment
35
-
36
- └ c = begin
37
- ~~~~~~~~~
38
- - |
39
- a.rb:25:0: [error] Cannot assign a value of type `(::Array[::Integer] | ::Symbol | ::Integer)` to a variable of type `::Integer`
40
- │ (::Array[::Integer] | ::Symbol | ::Integer) <: ::Integer
41
- │ ::Array[::Integer] <: ::Integer
42
- │ ::Object <: ::Integer
43
- │ ::BasicObject <: ::Integer
44
-
45
- │ Diagnostic ID: Ruby::IncompatibleAssignment
46
-
47
- └ e = begin
48
- ~~~~~~~~~
49
- - |
50
- a.rb:37:0: [error] Cannot allow method body have type `(::Integer | ::String)` because declared as type `::String`
51
- │ (::Integer | ::String) <: ::String
52
- │ ::Integer <: ::String
53
- │ ::Numeric <: ::String
54
- │ ::Object <: ::String
55
- │ ::BasicObject <: ::String
56
-
57
- │ Diagnostic ID: Ruby::MethodBodyTypeMismatch
58
-
59
- └ def foo(a)
60
- ~~~~~~~~~~
data/smoke/self/test.yaml DELETED
@@ -1,16 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:16:2: [error] Type `::Object` does not have method `baz`
7
- │ Diagnostic ID: Ruby::NoMethod
8
-
9
- └ baz
10
- ~~~
11
- - |
12
- a.rb:19:4: [error] Type `::Object` does not have method `baz`
13
- │ Diagnostic ID: Ruby::NoMethod
14
-
15
- └ baz
16
- ~~~
data/smoke/skip/test.yaml DELETED
@@ -1,16 +0,0 @@
1
- ---
2
- test:
3
- skip.rb:
4
- diagnostics:
5
- - |
6
- skip.rb:8:7: [error] Type `::Object` does not have method `no_such_method`
7
- │ Diagnostic ID: Ruby::NoMethod
8
-
9
- └ self.no_such_method
10
- ~~~~~~~~~~~~~~
11
- - |
12
- skip.rb:12:7: [error] Type `::Object` does not have method `no_such_method`
13
- │ Diagnostic ID: Ruby::NoMethod
14
-
15
- └ self.no_such_method
16
- ~~~~~~~~~~~~~~
@@ -1,4 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics: []
@@ -1,52 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:6:4: [error] Cannot assign a value of type `::Object` to a variable of type `::Integer`
7
- │ ::Object <: ::Integer
8
- │ ::BasicObject <: ::Integer
9
-
10
- │ Diagnostic ID: Ruby::IncompatibleAssignment
11
-
12
- └ a = super(x)
13
- ~~~~~~~~~~~~
14
- - |
15
- a.rb:7:4: [error] Cannot assign a value of type `::Object` to a variable of type `::Integer`
16
- │ ::Object <: ::Integer
17
- │ ::BasicObject <: ::Integer
18
-
19
- │ Diagnostic ID: Ruby::IncompatibleAssignment
20
-
21
- └ a = super
22
- ~~~~~~~~~
23
- - |
24
- a.rb:19:4: [error] Cannot detect the type of the expression
25
- │ Diagnostic ID: Ruby::FallbackAny
26
-
27
- └ super()
28
- ~~~~~~~
29
- - |
30
- a.rb:20:4: [error] Cannot detect the type of the expression
31
- │ Diagnostic ID: Ruby::FallbackAny
32
-
33
- └ super
34
- ~~~~~
35
- - |
36
- a.rb:26:4: [error] UnexpectedSuper
37
- │ Diagnostic ID: Ruby::UnexpectedSuper
38
-
39
- └ super()
40
- ~~~~~~~
41
- - |
42
- a.rb:28:4: [error] UnexpectedSuper
43
- │ Diagnostic ID: Ruby::UnexpectedSuper
44
-
45
- └ super
46
- ~~~~~
47
- - |
48
- a.rb:28:4: [error] Cannot detect the type of the expression
49
- │ Diagnostic ID: Ruby::FallbackAny
50
-
51
- └ super
52
- ~~~~~
@@ -1,12 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:1:0: [error] Cannot allow method body have type `nil` because declared as type `::String`
7
- │ nil <: ::String
8
-
9
- │ Diagnostic ID: Ruby::MethodBodyTypeMismatch
10
-
11
- └ def fizz_buzz(n)
12
- ~~~~~~~~~~~~~~~~
@@ -1,32 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:7:0: [error] Cannot assign a value of type `^() -> ::Hash[::Integer, ::Array[::Integer]]` to a variable of type `^() { (::Integer) -> void } -> void`
7
- │ ^() -> ::Hash[::Integer, ::Array[::Integer]] <: ^() { (::Integer) -> void } -> void
8
-
9
- │ Diagnostic ID: Ruby::IncompatibleAssignment
10
-
11
- └ each_node = -> (&b) { g.each_key(&b) }
12
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13
- - |
14
- a.rb:9:0: [error] Cannot assign a value of type `^(::Integer) -> ::Array[::Integer]` to a variable of type `^(::Integer) { (::Integer) -> void } -> void`
15
- │ ^(::Integer) -> ::Array[::Integer] <: ^(::Integer) { (::Integer) -> void } -> void
16
-
17
- │ Diagnostic ID: Ruby::IncompatibleAssignment
18
-
19
- └ each_child = -> (n, &b) { g[n].each(&b) }
20
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
- - |
22
- a.rb:12:0: [error] Cannot assign a value of type `::Array[::Integer]` to a variable of type `::Array[::String]`
23
- │ ::Array[::Integer] <: ::Array[::String]
24
- │ ::Integer <: ::String
25
- │ ::Numeric <: ::String
26
- │ ::Object <: ::String
27
- │ ::BasicObject <: ::String
28
-
29
- │ Diagnostic ID: Ruby::IncompatibleAssignment
30
-
31
- └ xs = TSort.tsort(each_node, each_child)
32
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1,33 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:7:4: [error] Type `(::Integer | ::String)` does not have method `foobar`
7
- │ Diagnostic ID: Ruby::NoMethod
8
-
9
- └ x.foobar()
10
- ~~~~~~
11
- - |
12
- a.rb:12:4: [error] Type `(::Integer | ::String | ::Symbol)` does not have method `foobar`
13
- │ Diagnostic ID: Ruby::NoMethod
14
-
15
- └ x.foobar
16
- ~~~~~~
17
- - |
18
- a.rb:17:4: [error] Type `1` does not have method `foobar`
19
- │ Diagnostic ID: Ruby::NoMethod
20
-
21
- └ x.foobar
22
- ~~~~~~
23
- - |
24
- a.rb:23:2: [error] Type annotation about `x` is incompatible since ::Integer <: ::String doesn't hold
25
- │ ::Integer <: ::String
26
- │ ::Numeric <: ::String
27
- │ ::Object <: ::String
28
- │ ::BasicObject <: ::String
29
-
30
- │ Diagnostic ID: Ruby::IncompatibleAnnotation
31
-
32
- └ x + 1
33
- ~~~~~
@@ -1,49 +0,0 @@
1
- ---
2
- test:
3
- a.rb:
4
- diagnostics:
5
- - |
6
- a.rb:6:4: [error] Cannot assign a value of type `::Integer` to a variable of type `::String`
7
- │ ::Integer <: ::String
8
- │ ::Numeric <: ::String
9
- │ ::Object <: ::String
10
- │ ::BasicObject <: ::String
11
-
12
- │ Diagnostic ID: Ruby::IncompatibleAssignment
13
-
14
- └ x = yield(3)
15
- ~~~~~~~~~~~~
16
- - |
17
- a.rb:8:10: [error] Cannot assign a value of type `::String` to an expression of type `::Integer`
18
- │ ::String <: ::Integer
19
- │ ::Object <: ::Integer
20
- │ ::BasicObject <: ::Integer
21
-
22
- │ Diagnostic ID: Ruby::IncompatibleAssignment
23
-
24
- └ yield(x)
25
- ~
26
- - |
27
- a.rb:13:4: [error] No block given for `yield`
28
- │ Diagnostic ID: Ruby::UnexpectedYield
29
-
30
- └ yield 4
31
- ~~~~~~~
32
- - |
33
- a.rb:13:4: [error] Cannot detect the type of the expression
34
- │ Diagnostic ID: Ruby::FallbackAny
35
-
36
- └ yield 4
37
- ~~~~~~~
38
- b.rb:
39
- diagnostics:
40
- - |
41
- b.rb:4:10: [error] Cannot assign a value of type `::String` to an expression of type `::Integer`
42
- │ ::String <: ::Integer
43
- │ ::Object <: ::Integer
44
- │ ::BasicObject <: ::Integer
45
-
46
- │ Diagnostic ID: Ruby::IncompatibleAssignment
47
-
48
- └ yield ""
49
- ~~