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,125 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 8
7
+ character: 0
8
+ end:
9
+ line: 8
10
+ character: 9
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot assign a value of type `::Integer` to a variable of type `::String`
14
+ ::Integer <: ::String
15
+ ::Numeric <: ::String
16
+ ::Object <: ::String
17
+ ::BasicObject <: ::String
18
+ code: Ruby::IncompatibleAssignment
19
+ - range:
20
+ start:
21
+ line: 10
22
+ character: 0
23
+ end:
24
+ line: 10
25
+ character: 17
26
+ severity: ERROR
27
+ message: |-
28
+ Cannot assign a value of type `::String` to a variable of type `::Integer`
29
+ ::String <: ::Integer
30
+ ::Object <: ::Integer
31
+ ::BasicObject <: ::Integer
32
+ code: Ruby::IncompatibleAssignment
33
+ - file: b.rb
34
+ diagnostics:
35
+ - range:
36
+ start:
37
+ line: 5
38
+ character: 2
39
+ end:
40
+ line: 5
41
+ character: 9
42
+ severity: ERROR
43
+ message: |-
44
+ Cannot break with a value of type `::Integer` because type `::Symbol` is assumed
45
+ ::Integer <: ::Symbol
46
+ ::Numeric <: ::Symbol
47
+ ::Object <: ::Symbol
48
+ ::BasicObject <: ::Symbol
49
+ code: Ruby::BreakTypeMismatch
50
+ - range:
51
+ start:
52
+ line: 10
53
+ character: 0
54
+ end:
55
+ line: 13
56
+ character: 3
57
+ severity: ERROR
58
+ message: |-
59
+ Cannot assign a value of type `(::Integer | ::Symbol)` to a variable of type `::String`
60
+ (::Integer | ::Symbol) <: ::String
61
+ ::Integer <: ::String
62
+ ::Numeric <: ::String
63
+ ::Object <: ::String
64
+ ::BasicObject <: ::String
65
+ code: Ruby::IncompatibleAssignment
66
+ - file: d.rb
67
+ diagnostics:
68
+ - range:
69
+ start:
70
+ line: 6
71
+ character: 0
72
+ end:
73
+ line: 6
74
+ character: 19
75
+ severity: ERROR
76
+ message: |-
77
+ Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]`
78
+ ::Array[::String] <: ::Array[::Float]
79
+ ::String <: ::Float
80
+ ::Object <: ::Float
81
+ ::BasicObject <: ::Float
82
+ code: Ruby::IncompatibleAssignment
83
+ - range:
84
+ start:
85
+ line: 8
86
+ character: 0
87
+ end:
88
+ line: 8
89
+ character: 23
90
+ severity: ERROR
91
+ message: |-
92
+ Cannot assign a value of type `::Array[::String]` to a variable of type `::Array[::Float]`
93
+ ::Array[::String] <: ::Array[::Float]
94
+ ::String <: ::Float
95
+ ::Object <: ::Float
96
+ ::BasicObject <: ::Float
97
+ code: Ruby::IncompatibleAssignment
98
+ - range:
99
+ start:
100
+ line: 10
101
+ character: 0
102
+ end:
103
+ line: 10
104
+ character: 29
105
+ severity: ERROR
106
+ message: |-
107
+ Cannot find compatible overloading of method `map` of type `::Array[::Integer]`
108
+ Method types:
109
+ def map: [U] () { (::Integer) -> U } -> ::Array[U]
110
+ | () -> ::Enumerator[::Integer, ::Array[untyped]]
111
+ code: Ruby::UnresolvedOverloading
112
+ - range:
113
+ start:
114
+ line: 11
115
+ character: 0
116
+ end:
117
+ line: 11
118
+ character: 21
119
+ severity: ERROR
120
+ message: |-
121
+ Cannot find compatible overloading of method `map` of type `::Array[::Integer]`
122
+ Method types:
123
+ def map: [U] () { (::Integer) -> U } -> ::Array[U]
124
+ | () -> ::Enumerator[::Integer, ::Array[untyped]]
125
+ code: Ruby::UnresolvedOverloading
@@ -0,0 +1,47 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 3
7
+ character: 0
8
+ end:
9
+ line: 13
10
+ character: 7
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot assign a value of type `(::Integer | ::Array[::String] | nil | ::String)` to a variable of type `::Integer`
14
+ (::Integer | ::Array[::String] | nil | ::String) <: ::Integer
15
+ ::Array[::String] <: ::Integer
16
+ ::Object <: ::Integer
17
+ ::BasicObject <: ::Integer
18
+ code: Ruby::IncompatibleAssignment
19
+ - range:
20
+ start:
21
+ line: 15
22
+ character: 0
23
+ end:
24
+ line: 18
25
+ character: 7
26
+ severity: ERROR
27
+ message: |-
28
+ Cannot assign a value of type `(::Integer | nil)` to a variable of type `::Integer`
29
+ (::Integer | nil) <: ::Integer
30
+ nil <: ::Integer
31
+ code: Ruby::IncompatibleAssignment
32
+ - range:
33
+ start:
34
+ line: 16
35
+ character: 9
36
+ end:
37
+ line: 16
38
+ character: 14
39
+ severity: ERROR
40
+ message: |-
41
+ Cannot find compatible overloading of method `+` of type `::Integer`
42
+ Method types:
43
+ def +: (::Integer) -> ::Integer
44
+ | (::Float) -> ::Float
45
+ | (::Rational) -> ::Rational
46
+ | (::Complex) -> ::Complex
47
+ code: Ruby::UnresolvedOverloading
@@ -0,0 +1,120 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 8
7
+ character: 9
8
+ end:
9
+ line: 8
10
+ character: 12
11
+ severity: ERROR
12
+ message: Method parameters are incompatible with declaration `() -> ::String`
13
+ code: Ruby::MethodArityMismatch
14
+ - range:
15
+ start:
16
+ line: 13
17
+ character: 2
18
+ end:
19
+ line: 15
20
+ character: 5
21
+ severity: ERROR
22
+ message: |-
23
+ Cannot allow method body have type `::Integer` because declared as type `::String`
24
+ ::Integer <: ::String
25
+ ::Numeric <: ::String
26
+ ::Object <: ::String
27
+ ::BasicObject <: ::String
28
+ code: Ruby::MethodBodyTypeMismatch
29
+ - range:
30
+ start:
31
+ line: 22
32
+ character: 2
33
+ end:
34
+ line: 24
35
+ character: 5
36
+ severity: ERROR
37
+ message: |-
38
+ Cannot allow method body have type `::String` because declared as type `::Integer`
39
+ ::String <: ::Integer
40
+ ::Object <: ::Integer
41
+ ::BasicObject <: ::Integer
42
+ code: Ruby::MethodBodyTypeMismatch
43
+ - file: c.rb
44
+ diagnostics:
45
+ - range:
46
+ start:
47
+ line: 1
48
+ character: 6
49
+ end:
50
+ line: 1
51
+ character: 7
52
+ severity: ERROR
53
+ message: "@dynamic annotation contains unknown method name `type`"
54
+ code: Ruby::UnexpectedDynamicMethod
55
+ - file: f.rb
56
+ diagnostics:
57
+ - range:
58
+ start:
59
+ line: 9
60
+ character: 0
61
+ end:
62
+ line: 9
63
+ character: 5
64
+ severity: ERROR
65
+ message: |-
66
+ Cannot assign a value of type `::_E` to a variable of type `::D`
67
+ ::_E <: ::D
68
+ code: Ruby::IncompatibleAssignment
69
+ - file: g.rb
70
+ diagnostics:
71
+ - range:
72
+ start:
73
+ line: 1
74
+ character: 6
75
+ end:
76
+ line: 1
77
+ character: 7
78
+ severity: ERROR
79
+ message: Cannot find implementation of method `::B#name`
80
+ code: Ruby::MethodDefinitionMissing
81
+ - range:
82
+ start:
83
+ line: 4
84
+ character: 6
85
+ end:
86
+ line: 4
87
+ character: 7
88
+ severity: ERROR
89
+ message: Cannot find implementation of method `::B#name`
90
+ code: Ruby::MethodDefinitionMissing
91
+ - file: i.rb
92
+ diagnostics:
93
+ - range:
94
+ start:
95
+ line: 4
96
+ character: 4
97
+ end:
98
+ line: 4
99
+ character: 15
100
+ severity: ERROR
101
+ message: |-
102
+ Cannot assign a value of type `::Integer` to a variable of type `::Symbol`
103
+ ::Integer <: ::Symbol
104
+ ::Numeric <: ::Symbol
105
+ ::Object <: ::Symbol
106
+ ::BasicObject <: ::Symbol
107
+ code: Ruby::IncompatibleAssignment
108
+ - range:
109
+ start:
110
+ line: 10
111
+ character: 4
112
+ end:
113
+ line: 10
114
+ character: 11
115
+ severity: ERROR
116
+ message: |-
117
+ Cannot find method `initialize` of type `::IncompatibleChild` with compatible arity
118
+ Method types:
119
+ def initialize: (name: ::String) -> untyped
120
+ code: Ruby::IncompatibleArguments
@@ -0,0 +1,129 @@
1
+ ---
2
+ - file: a.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 4
7
+ character: 0
8
+ end:
9
+ line: 4
10
+ character: 5
11
+ severity: ERROR
12
+ message: |-
13
+ Cannot assign a value of type `::Integer` to a variable of type `::String`
14
+ ::Integer <: ::String
15
+ ::Numeric <: ::String
16
+ ::Object <: ::String
17
+ ::BasicObject <: ::String
18
+ code: Ruby::IncompatibleAssignment
19
+ - range:
20
+ start:
21
+ line: 6
22
+ character: 4
23
+ end:
24
+ line: 6
25
+ character: 5
26
+ severity: ERROR
27
+ message: Cannot detect the type of the expression
28
+ code: Ruby::FallbackAny
29
+ - range:
30
+ start:
31
+ line: 14
32
+ character: 4
33
+ end:
34
+ line: 14
35
+ character: 9
36
+ severity: ERROR
37
+ message: |-
38
+ Cannot assign a value of type `::Integer` to a variable of type `::String`
39
+ ::Integer <: ::String
40
+ ::Numeric <: ::String
41
+ ::Object <: ::String
42
+ ::BasicObject <: ::String
43
+ code: Ruby::IncompatibleAssignment
44
+ - range:
45
+ start:
46
+ line: 16
47
+ character: 8
48
+ end:
49
+ line: 16
50
+ character: 9
51
+ severity: ERROR
52
+ message: Cannot detect the type of the expression
53
+ code: Ruby::FallbackAny
54
+ - range:
55
+ start:
56
+ line: 23
57
+ character: 0
58
+ end:
59
+ line: 23
60
+ character: 17
61
+ severity: ERROR
62
+ message: |-
63
+ Cannot assign a value of type `::Integer` to a variable of type `::String`
64
+ ::Integer <: ::String
65
+ ::Numeric <: ::String
66
+ ::Object <: ::String
67
+ ::BasicObject <: ::String
68
+ code: Ruby::IncompatibleAssignment
69
+ - range:
70
+ start:
71
+ line: 26
72
+ character: 4
73
+ end:
74
+ line: 26
75
+ character: 10
76
+ severity: ERROR
77
+ message: Cannot detect the type of the expression
78
+ code: Ruby::FallbackAny
79
+ - range:
80
+ start:
81
+ line: 26
82
+ character: 4
83
+ end:
84
+ line: 26
85
+ character: 15
86
+ severity: ERROR
87
+ message: Cannot detect the type of the expression
88
+ code: Ruby::FallbackAny
89
+ - range:
90
+ start:
91
+ line: 27
92
+ character: 0
93
+ end:
94
+ line: 27
95
+ character: 19
96
+ severity: ERROR
97
+ message: |-
98
+ Cannot assign a value of type `::Integer` to a variable of type `::String`
99
+ ::Integer <: ::String
100
+ ::Numeric <: ::String
101
+ ::Object <: ::String
102
+ ::BasicObject <: ::String
103
+ code: Ruby::IncompatibleAssignment
104
+ - file: b.rb
105
+ diagnostics:
106
+ - range:
107
+ start:
108
+ line: 3
109
+ character: 4
110
+ end:
111
+ line: 3
112
+ character: 17
113
+ severity: ERROR
114
+ message: |-
115
+ Cannot assign a value of type `::String` to a constant of type `::Integer`
116
+ ::String <: ::Integer
117
+ ::Object <: ::Integer
118
+ ::BasicObject <: ::Integer
119
+ code: Ruby::IncompatibleAssignment
120
+ - range:
121
+ start:
122
+ line: 5
123
+ character: 4
124
+ end:
125
+ line: 5
126
+ character: 8
127
+ severity: ERROR
128
+ message: Cannot find the declaration of constant `Baz2`
129
+ code: Ruby::UnknownConstantAssigned
@@ -0,0 +1,13 @@
1
+ ---
2
+ - file: a.rbs
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 4
7
+ character: 0
8
+ end:
9
+ line: 5
10
+ character: 3
11
+ severity: ERROR
12
+ message: Declaration of `::A` is duplicated
13
+ code: RBS::DuplicatedDeclaration
@@ -1,5 +1,8 @@
1
- target :test do
2
- typing_options :strict
3
- check "*.rb"
4
- signature "*.rbs"
1
+ all_sigs = Pathname.glob("*.rbs")
2
+
3
+ all_sigs.each do |path|
4
+ target path.basename(".rbs").to_s.to_sym do
5
+ typing_options :strict
6
+ signature path.to_s
7
+ end
5
8
  end