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
@@ -0,0 +1 @@
1
+ ["abc", "d", ""].to_h { |e| [e, e.size] }
File without changes
@@ -0,0 +1,11 @@
1
+ module Issue332
2
+ module TimeDurationExtensions
3
+ def -(other)
4
+ if other.is_a?(Duration)
5
+ Time.now
6
+ else
7
+ super(other)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Issue332
2
+ class Duration
3
+ end
4
+
5
+ interface _TimeDurationExtensions
6
+ def -: (Numeric other) -> Time
7
+ | (Time other) -> Float
8
+ end
9
+
10
+ module TimeDurationExtensions : _TimeDurationExtensions
11
+ def -: (Duration other) -> Time
12
+ | ...
13
+ end
14
+ end
15
+
16
+ class Time
17
+ prepend Issue332::TimeDurationExtensions
18
+ end
19
+
@@ -0,0 +1,8 @@
1
+ class Issue372
2
+ def f(&block)
3
+ end
4
+
5
+ def g(&block)
6
+ f(&block)
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ class Issue372
2
+ def f: () ?{ () -> void } -> void
3
+ def g: () ?{ () -> void } -> void
4
+ end
@@ -0,0 +1,4 @@
1
+ * = [1,2,3]
2
+ *, a = [1,2,3]
3
+
4
+ p a
@@ -0,0 +1,60 @@
1
+ ---
2
+ - file: issue_332.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 7
7
+ character: 8
8
+ end:
9
+ line: 7
10
+ character: 20
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot find compatible overloading of method `-` of type `(::Object & ::Issue332::_TimeDurationExtensions & ::Issue332::TimeDurationExtensions)`
14
+ Method types:
15
+ def -: (::Issue332::Duration) -> ::Time
16
+ | (::Numeric) -> ::Time
17
+ | (::Time) -> ::Float
18
+ code: Ruby::UnresolvedOverloading
19
+ - file: set_divide.rb
20
+ diagnostics:
21
+ - range:
22
+ start:
23
+ line: 2
24
+ character: 2
25
+ end:
26
+ line: 2
27
+ character: 10
28
+ severity: ERROR
29
+ message: Type `::Set[::String]` does not have method `ffffffff`
30
+ code: Ruby::NoMethod
31
+ - range:
32
+ start:
33
+ line: 5
34
+ character: 4
35
+ end:
36
+ line: 5
37
+ character: 9
38
+ severity: ERROR
39
+ message: Type `::String` does not have method `ggggg`
40
+ code: Ruby::NoMethod
41
+ - range:
42
+ start:
43
+ line: 7
44
+ character: 4
45
+ end:
46
+ line: 7
47
+ character: 9
48
+ severity: ERROR
49
+ message: Type `::String` does not have method `ggggg`
50
+ code: Ruby::NoMethod
51
+ - range:
52
+ start:
53
+ line: 11
54
+ character: 4
55
+ end:
56
+ line: 11
57
+ character: 9
58
+ severity: ERROR
59
+ message: Type `::String` does not have method `ggggg`
60
+ code: Ruby::NoMethod
@@ -0,0 +1,7 @@
1
+ Thread.new do
2
+ Thread.stop
3
+ end
4
+
5
+
6
+ Thread.start do
7
+ end
@@ -0,0 +1,79 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 3
7
+ character: 0
8
+ end:
9
+ line: 7
10
+ character: 7
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::Integer`
14
+ (::String | ::Integer) <: ::Integer
15
+ ::String <: ::Integer
16
+ ::Object <: ::Integer
17
+ ::BasicObject <: ::Integer
18
+ code: Ruby::IncompatibleAssignment
19
+ - range:
20
+ start:
21
+ line: 11
22
+ character: 0
23
+ end:
24
+ line: 11
25
+ character: 18
26
+ severity: ERROR
27
+ message: |-
28
+ Cannot assign a value of type `(::String | ::Integer)` to a variable of type `::Integer`
29
+ (::String | ::Integer) <: ::Integer
30
+ ::String <: ::Integer
31
+ ::Object <: ::Integer
32
+ ::BasicObject <: ::Integer
33
+ code: Ruby::IncompatibleAssignment
34
+ - range:
35
+ start:
36
+ line: 15
37
+ character: 0
38
+ end:
39
+ line: 21
40
+ character: 7
41
+ severity: ERROR
42
+ message: |-
43
+ Cannot assign a value of type `(::String | ::Symbol | ::Integer)` to a variable of type `::Integer`
44
+ (::String | ::Symbol | ::Integer) <: ::Integer
45
+ ::String <: ::Integer
46
+ ::Object <: ::Integer
47
+ ::BasicObject <: ::Integer
48
+ code: Ruby::IncompatibleAssignment
49
+ - range:
50
+ start:
51
+ line: 25
52
+ character: 0
53
+ end:
54
+ line: 33
55
+ character: 7
56
+ severity: ERROR
57
+ message: |-
58
+ Cannot assign a value of type `(::Array[::Integer] | ::Symbol | ::Integer)` to a variable of type `::Integer`
59
+ (::Array[::Integer] | ::Symbol | ::Integer) <: ::Integer
60
+ ::Array[::Integer] <: ::Integer
61
+ ::Object <: ::Integer
62
+ ::BasicObject <: ::Integer
63
+ code: Ruby::IncompatibleAssignment
64
+ - range:
65
+ start:
66
+ line: 37
67
+ character: 0
68
+ end:
69
+ line: 41
70
+ character: 3
71
+ severity: ERROR
72
+ message: |-
73
+ Cannot allow method body have type `(::Integer | ::String)` because declared as type `::String`
74
+ (::Integer | ::String) <: ::String
75
+ ::Integer <: ::String
76
+ ::Numeric <: ::String
77
+ ::Object <: ::String
78
+ ::BasicObject <: ::String
79
+ code: Ruby::MethodBodyTypeMismatch
@@ -0,0 +1,23 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 16
7
+ character: 2
8
+ end:
9
+ line: 16
10
+ character: 5
11
+ severity: ERROR
12
+ message: Type `::Object` does not have method `baz`
13
+ code: Ruby::NoMethod
14
+ - range:
15
+ start:
16
+ line: 19
17
+ character: 4
18
+ end:
19
+ line: 19
20
+ character: 7
21
+ severity: ERROR
22
+ message: Type `::Object` does not have method `baz`
23
+ code: Ruby::NoMethod
@@ -0,0 +1,23 @@
1
+ ---
2
+ - file: skip.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 8
7
+ character: 7
8
+ end:
9
+ line: 8
10
+ character: 21
11
+ severity: ERROR
12
+ message: Type `::Object` does not have method `no_such_method`
13
+ code: Ruby::NoMethod
14
+ - range:
15
+ start:
16
+ line: 12
17
+ character: 7
18
+ end:
19
+ line: 12
20
+ character: 21
21
+ severity: ERROR
22
+ message: Type `::Object` does not have method `no_such_method`
23
+ code: Ruby::NoMethod
@@ -0,0 +1 @@
1
+ --- []
@@ -0,0 +1,69 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 6
7
+ character: 4
8
+ end:
9
+ line: 6
10
+ character: 16
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot assign a value of type `::Object` to a variable of type `::Integer`
14
+ ::Object <: ::Integer
15
+ ::BasicObject <: ::Integer
16
+ code: Ruby::IncompatibleAssignment
17
+ - range:
18
+ start:
19
+ line: 7
20
+ character: 4
21
+ end:
22
+ line: 7
23
+ character: 13
24
+ severity: ERROR
25
+ message: |-
26
+ Cannot assign a value of type `::Object` to a variable of type `::Integer`
27
+ ::Object <: ::Integer
28
+ ::BasicObject <: ::Integer
29
+ code: Ruby::IncompatibleAssignment
30
+ - range:
31
+ start:
32
+ line: 19
33
+ character: 4
34
+ end:
35
+ line: 19
36
+ character: 11
37
+ severity: ERROR
38
+ message: Cannot detect the type of the expression
39
+ code: Ruby::FallbackAny
40
+ - range:
41
+ start:
42
+ line: 20
43
+ character: 4
44
+ end:
45
+ line: 20
46
+ character: 9
47
+ severity: ERROR
48
+ message: Cannot detect the type of the expression
49
+ code: Ruby::FallbackAny
50
+ - range:
51
+ start:
52
+ line: 26
53
+ character: 4
54
+ end:
55
+ line: 26
56
+ character: 11
57
+ severity: ERROR
58
+ message: No superclass method `baz` defined
59
+ code: Ruby::UnexpectedSuper
60
+ - range:
61
+ start:
62
+ line: 28
63
+ character: 4
64
+ end:
65
+ line: 28
66
+ character: 9
67
+ severity: ERROR
68
+ message: No superclass method `baz` defined
69
+ code: Ruby::UnexpectedSuper
@@ -0,0 +1,15 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 1
7
+ character: 0
8
+ end:
9
+ line: 3
10
+ character: 3
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot allow method body have type `nil` because declared as type `::String`
14
+ nil <: ::String
15
+ code: Ruby::MethodBodyTypeMismatch
@@ -2,5 +2,7 @@ target :test do
2
2
  signature "."
3
3
  check "."
4
4
 
5
+ typing_options :strict
6
+
5
7
  library "tsort"
6
8
  end
@@ -0,0 +1,63 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 7
7
+ character: 0
8
+ end:
9
+ line: 7
10
+ character: 38
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot assign a value of type `^() -> ::Hash[::Integer, ::Array[::Integer]]` to a variable of type `^() { (::Integer) -> void } -> void`
14
+ ^() -> ::Hash[::Integer, ::Array[::Integer]] <: ^() { (::Integer) -> void } -> void
15
+ code: Ruby::IncompatibleAssignment
16
+ - range:
17
+ start:
18
+ line: 7
19
+ character: 34
20
+ end:
21
+ line: 7
22
+ character: 35
23
+ severity: ERROR
24
+ message: Cannot detect the type of the expression
25
+ code: Ruby::FallbackAny
26
+ - range:
27
+ start:
28
+ line: 9
29
+ character: 0
30
+ end:
31
+ line: 9
32
+ character: 41
33
+ severity: ERROR
34
+ message: |-
35
+ Cannot assign a value of type `^(::Integer) -> ::Array[::Integer]` to a variable of type `^(::Integer) { (::Integer) -> void } -> void`
36
+ ^(::Integer) -> ::Array[::Integer] <: ^(::Integer) { (::Integer) -> void } -> void
37
+ code: Ruby::IncompatibleAssignment
38
+ - range:
39
+ start:
40
+ line: 9
41
+ character: 37
42
+ end:
43
+ line: 9
44
+ character: 38
45
+ severity: ERROR
46
+ message: Cannot detect the type of the expression
47
+ code: Ruby::FallbackAny
48
+ - range:
49
+ start:
50
+ line: 12
51
+ character: 0
52
+ end:
53
+ line: 12
54
+ character: 39
55
+ severity: ERROR
56
+ message: |-
57
+ Cannot assign a value of type `::Array[::Integer]` to a variable of type `::Array[::String]`
58
+ ::Array[::Integer] <: ::Array[::String]
59
+ ::Integer <: ::String
60
+ ::Numeric <: ::String
61
+ ::Object <: ::String
62
+ ::BasicObject <: ::String
63
+ code: Ruby::IncompatibleAssignment
@@ -0,0 +1,48 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 7
7
+ character: 4
8
+ end:
9
+ line: 7
10
+ character: 10
11
+ severity: ERROR
12
+ message: Type `(::Integer | ::String)` does not have method `foobar`
13
+ code: Ruby::NoMethod
14
+ - range:
15
+ start:
16
+ line: 12
17
+ character: 4
18
+ end:
19
+ line: 12
20
+ character: 10
21
+ severity: ERROR
22
+ message: Type `(::Integer | ::String | ::Symbol)` does not have method `foobar`
23
+ code: Ruby::NoMethod
24
+ - range:
25
+ start:
26
+ line: 17
27
+ character: 4
28
+ end:
29
+ line: 17
30
+ character: 10
31
+ severity: ERROR
32
+ message: Type `1` does not have method `foobar`
33
+ code: Ruby::NoMethod
34
+ - range:
35
+ start:
36
+ line: 23
37
+ character: 2
38
+ end:
39
+ line: 23
40
+ character: 7
41
+ severity: ERROR
42
+ message: |-
43
+ Type annotation about `x` is incompatible since ::Integer <: ::String doesn't hold
44
+ ::Integer <: ::String
45
+ ::Numeric <: ::String
46
+ ::Object <: ::String
47
+ ::BasicObject <: ::String
48
+ code: Ruby::IncompatibleAnnotation