steep 0.43.1 → 0.46.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +8 -0
  3. data/.github/workflows/ruby.yml +4 -2
  4. data/.gitignore +0 -1
  5. data/CHANGELOG.md +41 -0
  6. data/Gemfile +0 -1
  7. data/Gemfile.lock +77 -0
  8. data/bin/output_test.rb +8 -2
  9. data/lib/steep/ast/builtin.rb +7 -1
  10. data/lib/steep/ast/types/factory.rb +19 -25
  11. data/lib/steep/cli.rb +7 -1
  12. data/lib/steep/diagnostic/lsp_formatter.rb +59 -6
  13. data/lib/steep/diagnostic/ruby.rb +188 -60
  14. data/lib/steep/diagnostic/signature.rb +34 -0
  15. data/lib/steep/drivers/check.rb +3 -0
  16. data/lib/steep/drivers/init.rb +10 -3
  17. data/lib/steep/drivers/utils/driver_helper.rb +15 -0
  18. data/lib/steep/drivers/validate.rb +1 -1
  19. data/lib/steep/drivers/watch.rb +3 -0
  20. data/lib/steep/equatable.rb +21 -0
  21. data/lib/steep/index/source_index.rb +55 -5
  22. data/lib/steep/interface/block.rb +4 -0
  23. data/lib/steep/interface/function.rb +798 -579
  24. data/lib/steep/project/dsl.rb +105 -33
  25. data/lib/steep/project/options.rb +12 -53
  26. data/lib/steep/project/target.rb +21 -8
  27. data/lib/steep/server/interaction_worker.rb +239 -20
  28. data/lib/steep/server/master.rb +22 -1
  29. data/lib/steep/server/type_check_worker.rb +74 -9
  30. data/lib/steep/services/file_loader.rb +26 -19
  31. data/lib/steep/services/goto_service.rb +322 -0
  32. data/lib/steep/services/hover_content.rb +132 -80
  33. data/lib/steep/services/type_check_service.rb +25 -0
  34. data/lib/steep/source.rb +7 -10
  35. data/lib/steep/type_construction.rb +496 -518
  36. data/lib/steep/type_inference/block_params.rb +2 -5
  37. data/lib/steep/type_inference/method_params.rb +483 -0
  38. data/lib/steep/type_inference/send_args.rb +610 -128
  39. data/lib/steep/typing.rb +46 -21
  40. data/lib/steep/version.rb +1 -1
  41. data/lib/steep.rb +4 -1
  42. data/sample/Steepfile +10 -3
  43. data/sig/steep/type_inference/send_args.rbs +42 -0
  44. data/smoke/alias/Steepfile +2 -1
  45. data/smoke/and/Steepfile +2 -1
  46. data/smoke/array/Steepfile +2 -1
  47. data/smoke/array/test_expectations.yml +3 -3
  48. data/smoke/block/Steepfile +2 -2
  49. data/smoke/block/c.rb +0 -1
  50. data/smoke/case/Steepfile +2 -1
  51. data/smoke/class/Steepfile +2 -1
  52. data/smoke/class/test_expectations.yml +12 -15
  53. data/smoke/const/Steepfile +2 -1
  54. data/smoke/const/test_expectations.yml +0 -10
  55. data/smoke/diagnostics/Steepfile +2 -1
  56. data/smoke/diagnostics/a.rbs +0 -4
  57. data/smoke/diagnostics/different_method_parameter_kind.rb +9 -0
  58. data/smoke/diagnostics/method_arity_mismatch.rb +2 -2
  59. data/smoke/diagnostics/method_parameter_mismatch.rb +10 -0
  60. data/smoke/diagnostics/test_expectations.yml +108 -57
  61. data/smoke/diagnostics-rbs/Steepfile +1 -1
  62. data/smoke/diagnostics-rbs/mixin-class-error.rbs +6 -0
  63. data/smoke/diagnostics-rbs/test_expectations.yml +12 -0
  64. data/smoke/diagnostics-rbs-duplicated/Steepfile +2 -1
  65. data/smoke/diagnostics-ruby-unsat/Steepfile +6 -0
  66. data/smoke/diagnostics-ruby-unsat/a.rbs +3 -0
  67. data/smoke/diagnostics-ruby-unsat/test_expectations.yml +27 -0
  68. data/smoke/{diagnostics → diagnostics-ruby-unsat}/unsatisfiable_constraint.rb +0 -1
  69. data/smoke/dstr/Steepfile +2 -1
  70. data/smoke/ensure/Steepfile +2 -1
  71. data/smoke/ensure/test_expectations.yml +3 -3
  72. data/smoke/enumerator/Steepfile +2 -1
  73. data/smoke/enumerator/test_expectations.yml +1 -1
  74. data/smoke/extension/Steepfile +2 -1
  75. data/smoke/hash/Steepfile +2 -1
  76. data/smoke/hello/Steepfile +2 -1
  77. data/smoke/if/Steepfile +2 -1
  78. data/smoke/implements/Steepfile +2 -1
  79. data/smoke/initialize/Steepfile +2 -1
  80. data/smoke/integer/Steepfile +2 -1
  81. data/smoke/interface/Steepfile +2 -1
  82. data/smoke/kwbegin/Steepfile +2 -1
  83. data/smoke/lambda/Steepfile +2 -1
  84. data/smoke/literal/Steepfile +2 -1
  85. data/smoke/literal/test_expectations.yml +2 -2
  86. data/smoke/map/Steepfile +2 -1
  87. data/smoke/method/Steepfile +2 -1
  88. data/smoke/method/test_expectations.yml +11 -10
  89. data/smoke/module/Steepfile +2 -1
  90. data/smoke/regexp/Steepfile +2 -1
  91. data/smoke/regression/Steepfile +2 -1
  92. data/smoke/regression/issue_372.rb +8 -0
  93. data/smoke/regression/issue_372.rbs +4 -0
  94. data/smoke/regression/test_expectations.yml +0 -12
  95. data/smoke/rescue/Steepfile +2 -1
  96. data/smoke/rescue/test_expectations.yml +3 -3
  97. data/smoke/self/Steepfile +2 -1
  98. data/smoke/skip/Steepfile +2 -1
  99. data/smoke/stdout/Steepfile +2 -1
  100. data/smoke/super/Steepfile +2 -1
  101. data/smoke/toplevel/Steepfile +2 -1
  102. data/smoke/toplevel/test_expectations.yml +3 -3
  103. data/smoke/tsort/Steepfile +4 -5
  104. data/smoke/tsort/test_expectations.yml +2 -2
  105. data/smoke/type_case/Steepfile +2 -1
  106. data/smoke/unexpected/Steepfile +2 -1
  107. data/smoke/yield/Steepfile +2 -1
  108. data/steep.gemspec +2 -2
  109. metadata +24 -10
@@ -2,7 +2,7 @@ all_sigs = Pathname.glob("*.rbs")
2
2
 
3
3
  all_sigs.each do |path|
4
4
  target path.basename(".rbs").to_s.to_sym do
5
- typing_options :strict
6
5
  signature path.to_s
6
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
7
7
  end
8
8
  end
@@ -0,0 +1,6 @@
1
+ class Foo
2
+ end
3
+
4
+ class Bar
5
+ include Foo
6
+ end
@@ -229,3 +229,15 @@
229
229
  severity: ERROR
230
230
  message: Cannot find type `ZZZ`
231
231
  code: RBS::UnknownTypeName
232
+ - file: mixin-class-error.rbs
233
+ diagnostics:
234
+ - range:
235
+ start:
236
+ line: 5
237
+ character: 2
238
+ end:
239
+ line: 5
240
+ character: 13
241
+ severity: ERROR
242
+ message: Cannot include a class `::Foo` in the definition of `::Bar`
243
+ code: RBS::MixinClassError
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -0,0 +1,6 @@
1
+ target :test do
2
+ check "*.rb"
3
+ signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
6
+ end
@@ -0,0 +1,3 @@
1
+ class UnsatisfiableConstraint
2
+ def foo: [A, B] (A) { (A) -> void } -> B
3
+ end
@@ -0,0 +1,27 @@
1
+ ---
2
+ - file: unsatisfiable_constraint.rb
3
+ diagnostics:
4
+ - range:
5
+ start:
6
+ line: 3
7
+ character: 0
8
+ end:
9
+ line: 6
10
+ character: 3
11
+ severity: ERROR
12
+ message: |-
13
+ Unsatisfiable constraint `::Array[untyped] <: A(2) <: ::String` is generated through (A(2)) { (A(2)) -> void } -> B(3)
14
+ ::Array[untyped] <: ::String
15
+ ::Object <: ::String
16
+ ::BasicObject <: ::String
17
+ code: Ruby::UnsatisfiableConstraint
18
+ - range:
19
+ start:
20
+ line: 5
21
+ character: 4
22
+ end:
23
+ line: 5
24
+ character: 7
25
+ severity: ERROR
26
+ message: Type `::String` does not have method `foo`
27
+ code: Ruby::NoMethod
@@ -1,4 +1,3 @@
1
-
2
1
  test = UnsatisfiableConstraint.new
3
2
 
4
3
  test.foo([]) do |x|
data/smoke/dstr/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -32,10 +32,10 @@
32
32
  - range:
33
33
  start:
34
34
  line: 13
35
- character: 0
35
+ character: 4
36
36
  end:
37
- line: 18
38
- character: 3
37
+ line: 13
38
+ character: 7
39
39
  severity: ERROR
40
40
  message: |-
41
41
  Cannot allow method body have type `::Integer` because declared as type `::String`
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -102,7 +102,7 @@
102
102
  Cannot find compatible overloading of method `with_object` of type `::Enumerator[::Integer, ::Array[::Integer]]`
103
103
  Method types:
104
104
  def with_object: [U] (U) { (::Integer, U) -> untyped } -> U
105
- | [U] (U) -> ::Enumerator[[::Integer, U], ::Array[::Integer]]
105
+ | [U] (U) -> ::Enumerator[[::Integer, U], U]
106
106
  code: Ruby::UnresolvedOverloading
107
107
  - range:
108
108
  start:
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
data/smoke/hash/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
data/smoke/if/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -101,6 +101,6 @@
101
101
  character: 15
102
102
  severity: ERROR
103
103
  message: |-
104
- Cannot assign a value of type `::Symbol` to an expression of type `:foo`
104
+ Cannot pass a value of type `::Symbol` as an argument of type `:foo`
105
105
  ::Symbol <: :foo
106
- code: Ruby::IncompatibleAssignment
106
+ code: Ruby::ArgumentTypeMismatch
data/smoke/map/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -4,10 +4,10 @@
4
4
  - range:
5
5
  start:
6
6
  line: 3
7
- character: 0
7
+ character: 4
8
8
  end:
9
- line: 11
10
- character: 3
9
+ line: 3
10
+ character: 7
11
11
  severity: ERROR
12
12
  message: |-
13
13
  Cannot allow method body have type `::Integer` because declared as type `::String`
@@ -49,13 +49,14 @@
49
49
  - range:
50
50
  start:
51
51
  line: 15
52
- character: 7
52
+ character: 11
53
53
  end:
54
54
  line: 15
55
- character: 13
55
+ character: 12
56
56
  severity: ERROR
57
- message: Method parameters are incompatible with declaration `(::Integer) -> ::String`
58
- code: Ruby::MethodArityMismatch
57
+ message: The method parameter is incompatible with the declaration `(::Integer)
58
+ -> ::String`
59
+ code: Ruby::MethodParameterMismatch
59
60
  - range:
60
61
  start:
61
62
  line: 18
@@ -76,10 +77,10 @@
76
77
  - range:
77
78
  start:
78
79
  line: 4
79
- character: 2
80
+ character: 6
80
81
  end:
81
- line: 6
82
- character: 5
82
+ line: 4
83
+ character: 9
83
84
  severity: ERROR
84
85
  message: |-
85
86
  Cannot allow method body have type `::Symbol` because declared as type `(::Integer | ::String)`
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,6 +1,7 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
5
4
  library "set"
5
+
6
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
6
7
  end
@@ -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
@@ -58,15 +58,3 @@
58
58
  severity: ERROR
59
59
  message: Type `::String` does not have method `ggggg`
60
60
  code: Ruby::NoMethod
61
- - file: thread.rb
62
- diagnostics:
63
- - range:
64
- start:
65
- line: 6
66
- character: 13
67
- end:
68
- line: 7
69
- character: 3
70
- severity: ERROR
71
- message: The method cannot be called with a block
72
- code: Ruby::UnexpectedBlockGiven
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -64,10 +64,10 @@
64
64
  - range:
65
65
  start:
66
66
  line: 37
67
- character: 0
67
+ character: 4
68
68
  end:
69
- line: 41
70
- character: 3
69
+ line: 37
70
+ character: 7
71
71
  severity: ERROR
72
72
  message: |-
73
73
  Cannot allow method body have type `(::Integer | ::String)` because declared as type `::String`
data/smoke/self/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
data/smoke/skip/Steepfile CHANGED
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end
@@ -1,5 +1,6 @@
1
1
  target :test do
2
- typing_options :strict
3
2
  check "*.rb"
4
3
  signature "*.rbs"
4
+
5
+ configure_code_diagnostics(Steep::Diagnostic::Ruby.all_error)
5
6
  end