steep-relaxed 1.9.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.gitmodules +0 -0
  4. data/CHANGELOG.md +1032 -0
  5. data/LICENSE +21 -0
  6. data/README.md +260 -0
  7. data/Rakefile +227 -0
  8. data/STDGEM_DEPENDENCIES.txt +59 -0
  9. data/Steepfile +68 -0
  10. data/bin/console +14 -0
  11. data/bin/generate-diagnostics-docs.rb +112 -0
  12. data/bin/mem_graph.rb +67 -0
  13. data/bin/mem_prof.rb +102 -0
  14. data/bin/output_rebaseline.rb +34 -0
  15. data/bin/output_test.rb +60 -0
  16. data/bin/rbs +20 -0
  17. data/bin/rbs-inline +19 -0
  18. data/bin/setup +9 -0
  19. data/bin/stackprof_test.rb +19 -0
  20. data/bin/steep +19 -0
  21. data/bin/steep-check.rb +251 -0
  22. data/bin/steep-prof +16 -0
  23. data/doc/narrowing.md +195 -0
  24. data/doc/shape.md +194 -0
  25. data/exe/steep +18 -0
  26. data/guides/README.md +5 -0
  27. data/guides/src/gem-rbs-collection/gem-rbs-collection.md +126 -0
  28. data/guides/src/getting-started/getting-started.md +163 -0
  29. data/guides/src/nil-optional/nil-optional.md +195 -0
  30. data/lib/steep/annotation_parser.rb +199 -0
  31. data/lib/steep/ast/annotation/collection.rb +172 -0
  32. data/lib/steep/ast/annotation.rb +137 -0
  33. data/lib/steep/ast/builtin.rb +104 -0
  34. data/lib/steep/ast/ignore.rb +148 -0
  35. data/lib/steep/ast/node/type_application.rb +88 -0
  36. data/lib/steep/ast/node/type_assertion.rb +81 -0
  37. data/lib/steep/ast/types/any.rb +35 -0
  38. data/lib/steep/ast/types/boolean.rb +45 -0
  39. data/lib/steep/ast/types/bot.rb +35 -0
  40. data/lib/steep/ast/types/class.rb +43 -0
  41. data/lib/steep/ast/types/factory.rb +557 -0
  42. data/lib/steep/ast/types/helper.rb +40 -0
  43. data/lib/steep/ast/types/instance.rb +42 -0
  44. data/lib/steep/ast/types/intersection.rb +93 -0
  45. data/lib/steep/ast/types/literal.rb +59 -0
  46. data/lib/steep/ast/types/logic.rb +84 -0
  47. data/lib/steep/ast/types/name.rb +128 -0
  48. data/lib/steep/ast/types/nil.rb +41 -0
  49. data/lib/steep/ast/types/proc.rb +117 -0
  50. data/lib/steep/ast/types/record.rb +79 -0
  51. data/lib/steep/ast/types/self.rb +43 -0
  52. data/lib/steep/ast/types/shared_instance.rb +11 -0
  53. data/lib/steep/ast/types/top.rb +35 -0
  54. data/lib/steep/ast/types/tuple.rb +60 -0
  55. data/lib/steep/ast/types/union.rb +97 -0
  56. data/lib/steep/ast/types/var.rb +65 -0
  57. data/lib/steep/ast/types/void.rb +35 -0
  58. data/lib/steep/cli.rb +401 -0
  59. data/lib/steep/diagnostic/deprecated/else_on_exhaustive_case.rb +20 -0
  60. data/lib/steep/diagnostic/deprecated/unknown_constant_assigned.rb +28 -0
  61. data/lib/steep/diagnostic/helper.rb +18 -0
  62. data/lib/steep/diagnostic/lsp_formatter.rb +78 -0
  63. data/lib/steep/diagnostic/result_printer2.rb +48 -0
  64. data/lib/steep/diagnostic/ruby.rb +1221 -0
  65. data/lib/steep/diagnostic/signature.rb +570 -0
  66. data/lib/steep/drivers/annotations.rb +52 -0
  67. data/lib/steep/drivers/check.rb +339 -0
  68. data/lib/steep/drivers/checkfile.rb +210 -0
  69. data/lib/steep/drivers/diagnostic_printer.rb +105 -0
  70. data/lib/steep/drivers/init.rb +66 -0
  71. data/lib/steep/drivers/langserver.rb +56 -0
  72. data/lib/steep/drivers/print_project.rb +113 -0
  73. data/lib/steep/drivers/stats.rb +203 -0
  74. data/lib/steep/drivers/utils/driver_helper.rb +143 -0
  75. data/lib/steep/drivers/utils/jobs_option.rb +26 -0
  76. data/lib/steep/drivers/vendor.rb +27 -0
  77. data/lib/steep/drivers/watch.rb +194 -0
  78. data/lib/steep/drivers/worker.rb +58 -0
  79. data/lib/steep/equatable.rb +23 -0
  80. data/lib/steep/expectations.rb +228 -0
  81. data/lib/steep/index/rbs_index.rb +350 -0
  82. data/lib/steep/index/signature_symbol_provider.rb +185 -0
  83. data/lib/steep/index/source_index.rb +167 -0
  84. data/lib/steep/interface/block.rb +103 -0
  85. data/lib/steep/interface/builder.rb +843 -0
  86. data/lib/steep/interface/function.rb +1090 -0
  87. data/lib/steep/interface/method_type.rb +330 -0
  88. data/lib/steep/interface/shape.rb +239 -0
  89. data/lib/steep/interface/substitution.rb +159 -0
  90. data/lib/steep/interface/type_param.rb +115 -0
  91. data/lib/steep/located_value.rb +20 -0
  92. data/lib/steep/method_name.rb +42 -0
  93. data/lib/steep/module_helper.rb +24 -0
  94. data/lib/steep/node_helper.rb +273 -0
  95. data/lib/steep/path_helper.rb +30 -0
  96. data/lib/steep/project/dsl.rb +268 -0
  97. data/lib/steep/project/group.rb +31 -0
  98. data/lib/steep/project/options.rb +63 -0
  99. data/lib/steep/project/pattern.rb +59 -0
  100. data/lib/steep/project/target.rb +92 -0
  101. data/lib/steep/project.rb +78 -0
  102. data/lib/steep/rake_task.rb +132 -0
  103. data/lib/steep/range_extension.rb +29 -0
  104. data/lib/steep/server/base_worker.rb +97 -0
  105. data/lib/steep/server/change_buffer.rb +73 -0
  106. data/lib/steep/server/custom_methods.rb +77 -0
  107. data/lib/steep/server/delay_queue.rb +45 -0
  108. data/lib/steep/server/interaction_worker.rb +492 -0
  109. data/lib/steep/server/lsp_formatter.rb +455 -0
  110. data/lib/steep/server/master.rb +922 -0
  111. data/lib/steep/server/target_group_files.rb +205 -0
  112. data/lib/steep/server/type_check_controller.rb +366 -0
  113. data/lib/steep/server/type_check_worker.rb +303 -0
  114. data/lib/steep/server/work_done_progress.rb +64 -0
  115. data/lib/steep/server/worker_process.rb +176 -0
  116. data/lib/steep/services/completion_provider.rb +802 -0
  117. data/lib/steep/services/content_change.rb +61 -0
  118. data/lib/steep/services/file_loader.rb +74 -0
  119. data/lib/steep/services/goto_service.rb +441 -0
  120. data/lib/steep/services/hover_provider/rbs.rb +88 -0
  121. data/lib/steep/services/hover_provider/ruby.rb +221 -0
  122. data/lib/steep/services/hover_provider/singleton_methods.rb +20 -0
  123. data/lib/steep/services/path_assignment.rb +46 -0
  124. data/lib/steep/services/signature_help_provider.rb +202 -0
  125. data/lib/steep/services/signature_service.rb +428 -0
  126. data/lib/steep/services/stats_calculator.rb +68 -0
  127. data/lib/steep/services/type_check_service.rb +394 -0
  128. data/lib/steep/services/type_name_completion.rb +236 -0
  129. data/lib/steep/signature/validator.rb +651 -0
  130. data/lib/steep/source/ignore_ranges.rb +69 -0
  131. data/lib/steep/source.rb +691 -0
  132. data/lib/steep/subtyping/cache.rb +30 -0
  133. data/lib/steep/subtyping/check.rb +1113 -0
  134. data/lib/steep/subtyping/constraints.rb +341 -0
  135. data/lib/steep/subtyping/relation.rb +101 -0
  136. data/lib/steep/subtyping/result.rb +324 -0
  137. data/lib/steep/subtyping/variable_variance.rb +89 -0
  138. data/lib/steep/test.rb +9 -0
  139. data/lib/steep/thread_waiter.rb +43 -0
  140. data/lib/steep/type_construction.rb +5183 -0
  141. data/lib/steep/type_inference/block_params.rb +416 -0
  142. data/lib/steep/type_inference/case_when.rb +303 -0
  143. data/lib/steep/type_inference/constant_env.rb +56 -0
  144. data/lib/steep/type_inference/context.rb +195 -0
  145. data/lib/steep/type_inference/logic_type_interpreter.rb +613 -0
  146. data/lib/steep/type_inference/method_call.rb +193 -0
  147. data/lib/steep/type_inference/method_params.rb +531 -0
  148. data/lib/steep/type_inference/multiple_assignment.rb +194 -0
  149. data/lib/steep/type_inference/send_args.rb +712 -0
  150. data/lib/steep/type_inference/type_env.rb +341 -0
  151. data/lib/steep/type_inference/type_env_builder.rb +138 -0
  152. data/lib/steep/typing.rb +321 -0
  153. data/lib/steep/version.rb +3 -0
  154. data/lib/steep.rb +369 -0
  155. data/manual/annotations.md +181 -0
  156. data/manual/ignore.md +20 -0
  157. data/manual/ruby-diagnostics.md +1879 -0
  158. data/sample/Steepfile +22 -0
  159. data/sample/lib/conference.rb +49 -0
  160. data/sample/lib/length.rb +35 -0
  161. data/sample/sig/conference.rbs +42 -0
  162. data/sample/sig/generics.rbs +15 -0
  163. data/sample/sig/length.rbs +34 -0
  164. data/steep-relaxed.gemspec +56 -0
  165. metadata +340 -0
@@ -0,0 +1,1879 @@
1
+ # Ruby Code Diagnostics
2
+
3
+ ## Configuration Templates
4
+ Steep provides several templates to configure diagnostics for Ruby code.
5
+ You can use these templates or customize them to suit your needs via `#configure_code_diagnostics` method in `Steepfile`.
6
+
7
+ The following templates are available:
8
+
9
+ <dl>
10
+ <dt><code>Ruby.all_error</code></dt>
11
+ <dd>This template reports everything as an error.
12
+
13
+ </dd>
14
+ <dt><code>Ruby.default</code></dt>
15
+ <dd>This template detects inconsistencies between RBS and Ruby code APIs.
16
+
17
+ </dd>
18
+ <dt><code>Ruby.lenient</code></dt>
19
+ <dd>This template detects inconsistent definition in Ruby code with respect to your RBS definition.
20
+
21
+ </dd>
22
+ <dt><code>Ruby.silent</code></dt>
23
+ <dd>This template reports nothing.
24
+
25
+ </dd>
26
+ <dt><code>Ruby.strict</code></dt>
27
+ <dd>This template helps you keeping your codebase (almost) type-safe.
28
+
29
+ You can start with this template to review the problems reported on the project,
30
+ and you can ignore some kind of errors.
31
+
32
+ </dd>
33
+ </dl>
34
+
35
+ <a name='Ruby::AnnotationSyntaxError'></a>
36
+ ## Ruby::AnnotationSyntaxError
37
+
38
+ A type annotation has a syntax error.
39
+
40
+ ### Ruby code
41
+
42
+ ```ruby
43
+ # @type var foo: () ->
44
+ ```
45
+
46
+ ### Diagnostic
47
+
48
+ ```
49
+ test.rb:1:2: [error] Type annotation has a syntax error: Syntax error caused by token `pEOF`
50
+ │ Diagnostic ID: Ruby::AnnotationSyntaxError
51
+
52
+ └ # @type method foo: () ->
53
+ ~~~~~~~~~~~~~~~~~~~~~~~
54
+ ```
55
+
56
+
57
+ ### Severity
58
+
59
+ | all_error | strict | default | lenient | silent |
60
+ | - | - | - | - | - |
61
+ | error | error | error | error | - |
62
+
63
+ <a name='Ruby::ArgumentTypeMismatch'></a>
64
+ ## Ruby::ArgumentTypeMismatch
65
+
66
+ A method call has an argument that has an incompatible type to the type of the parameter.
67
+
68
+ ### Ruby code
69
+
70
+ ```ruby
71
+ '1' + 1
72
+ ```
73
+
74
+ ### Diagnostic
75
+
76
+ ```
77
+ test.rb:1:6: [error] Cannot pass a value of type `::Integer` as an argument of type `::string`
78
+ │ ::Integer <: ::string
79
+ │ ::Integer <: (::String | ::_ToStr)
80
+ │ ::Integer <: ::String
81
+ │ ::Numeric <: ::String
82
+ │ ::Object <: ::String
83
+ │ ::BasicObject <: ::String
84
+
85
+ │ Diagnostic ID: Ruby::ArgumentTypeMismatch
86
+
87
+ └ '1' + 1
88
+ ~
89
+ ```
90
+
91
+
92
+ ### Severity
93
+
94
+ | all_error | strict | default | lenient | silent |
95
+ | - | - | - | - | - |
96
+ | error | error | error | information | - |
97
+
98
+ <a name='Ruby::BlockBodyTypeMismatch'></a>
99
+ ## Ruby::BlockBodyTypeMismatch
100
+
101
+ The type of the block body is incompatible with the expected type.
102
+
103
+ ### RBS
104
+
105
+ ```rbs
106
+ class Foo
107
+ def foo: () { () -> Integer } -> void
108
+ end
109
+ ```
110
+
111
+ ### Ruby code
112
+
113
+ ```ruby
114
+ Foo.new.foo { "" }
115
+ ```
116
+
117
+ ### Diagnostic
118
+
119
+ ```
120
+ test.rb:1:12: [warning] Cannot allow block body have type `::String` because declared as type `::Integer`
121
+ │ ::String <: ::Integer
122
+ │ ::Object <: ::Integer
123
+ │ ::BasicObject <: ::Integer
124
+
125
+ │ Diagnostic ID: Ruby::BlockBodyTypeMismatch
126
+
127
+ └ Foo.new.foo { "" }
128
+ ~~~~~~
129
+ ```
130
+
131
+
132
+ ### Severity
133
+
134
+ | all_error | strict | default | lenient | silent |
135
+ | - | - | - | - | - |
136
+ | error | error | warning | information | - |
137
+
138
+ <a name='Ruby::BlockTypeMismatch'></a>
139
+ ## Ruby::BlockTypeMismatch
140
+
141
+ A method call passes an object as a block, but the type is incompatible with the method type.
142
+
143
+ ### Ruby code
144
+
145
+ ```ruby
146
+ multi = ->(x, y) { x * y } #: ^(Integer, Integer) -> Integer
147
+ [1, 2, 3].map(&multi)
148
+ ```
149
+
150
+ ### Diagnostic
151
+
152
+ ```
153
+ test.rb:2:14: [error] Cannot pass a value of type `^(::Integer, ::Integer) -> ::Integer` as a block-pass-argument of type `^(::Integer) -> U(1)`
154
+ │ ^(::Integer, ::Integer) -> ::Integer <: ^(::Integer) -> U(1)
155
+ │ (Params are incompatible)
156
+
157
+ │ Diagnostic ID: Ruby::BlockTypeMismatch
158
+
159
+ └ [1, 2, 3].map(&multi)
160
+ ~~~~~~
161
+ ```
162
+
163
+
164
+ ### Severity
165
+
166
+ | all_error | strict | default | lenient | silent |
167
+ | - | - | - | - | - |
168
+ | error | error | warning | information | - |
169
+
170
+ <a name='Ruby::BreakTypeMismatch'></a>
171
+ ## Ruby::BreakTypeMismatch
172
+
173
+ A `break` statement has a value that has an incompatible type to the type of the destination.
174
+
175
+ ### Ruby code
176
+
177
+ ```ruby
178
+ 123.tap { break "" }
179
+ ```
180
+
181
+ ### Diagnostic
182
+
183
+ ```
184
+ test.rb:1:10: [error] Cannot break with a value of type `::String` because type `::Integer` is assumed
185
+ │ ::String <: ::Integer
186
+ │ ::Object <: ::Integer
187
+ │ ::BasicObject <: ::Integer
188
+
189
+ │ Diagnostic ID: Ruby::BreakTypeMismatch
190
+
191
+ └ 123.tap { break "" }
192
+ ~~~~~~~~
193
+ ```
194
+
195
+
196
+ ### Severity
197
+
198
+ | all_error | strict | default | lenient | silent |
199
+ | - | - | - | - | - |
200
+ | error | error | hint | hint | - |
201
+
202
+ <a name='Ruby::ClassModuleMismatch'></a>
203
+ ## Ruby::ClassModuleMismatch
204
+
205
+ A class (or module) definition in Ruby code has a module (or class) in RBS.
206
+
207
+ ### Ruby code
208
+
209
+ ```ruby
210
+ module Object
211
+ end
212
+
213
+ class Kernel
214
+ end
215
+ ```
216
+
217
+ ### Diagnostic
218
+
219
+ ```
220
+ test.rb:1:7: [error] ::Object is declared as a class in RBS
221
+ │ Diagnostic ID: Ruby::ClassModuleMismatch
222
+
223
+ └ module Object
224
+ ~~~~~~
225
+
226
+ test.rb:4:6: [error] ::Kernel is declared as a module in RBS
227
+ │ Diagnostic ID: Ruby::ClassModuleMismatch
228
+
229
+ └ class Kernel
230
+ ~~~~~~
231
+ ```
232
+
233
+
234
+ ### Severity
235
+
236
+ | all_error | strict | default | lenient | silent |
237
+ | - | - | - | - | - |
238
+ | error | error | error | - | - |
239
+
240
+ <a name='Ruby::DifferentMethodParameterKind'></a>
241
+ ## Ruby::DifferentMethodParameterKind
242
+
243
+ The method has a parameter with different kind from the RBS definition.
244
+
245
+ ### RBS
246
+
247
+ ```rbs
248
+ class Foo
249
+ def foo: (String?) -> void
250
+ end
251
+ ```
252
+
253
+ ### Ruby code
254
+
255
+ ```ruby
256
+ class Foo
257
+ def foo(x=nil)
258
+ end
259
+ end
260
+ ```
261
+
262
+ ### Diagnostic
263
+
264
+ ```
265
+ test.rb:2:10: [hint] The method parameter has different kind from the declaration `((::String | nil)) -> void`
266
+ │ Diagnostic ID: Ruby::DifferentMethodParameterKind
267
+
268
+ └ def foo(x=nil)
269
+ ~~~~~
270
+ ```
271
+
272
+
273
+ ### Severity
274
+
275
+ | all_error | strict | default | lenient | silent |
276
+ | - | - | - | - | - |
277
+ | error | error | hint | - | - |
278
+
279
+ <a name='Ruby::FallbackAny'></a>
280
+ ## Ruby::FallbackAny
281
+
282
+ Unable to determine the type of an expression for any reason.
283
+
284
+ ### Ruby code
285
+
286
+ ```ruby
287
+ @foo
288
+ ```
289
+
290
+ ### Diagnostic
291
+
292
+ ```
293
+ test.rb:1:0: [error] Cannot detect the type of the expression
294
+ │ Diagnostic ID: Ruby::FallbackAny
295
+
296
+ └ @foo
297
+ ~~~~
298
+ ```
299
+
300
+
301
+ ### Severity
302
+
303
+ | all_error | strict | default | lenient | silent |
304
+ | - | - | - | - | - |
305
+ | error | warning | hint | - | - |
306
+
307
+ <a name='Ruby::FalseAssertion'></a>
308
+ ## Ruby::FalseAssertion
309
+
310
+ The type assertion cannot hold.
311
+
312
+ ### Ruby code
313
+
314
+ ```ruby
315
+ array = [] #: Array[Integer]
316
+ hash = array #: Hash[Symbol, String]
317
+ ```
318
+
319
+ ### Diagnostic
320
+
321
+ ```
322
+ test.rb:2:7: [error] Assertion cannot hold: no relationship between inferred type (`::Array[::Integer]`) and asserted type (`::Hash[::Symbol, ::String]`)
323
+ │ Diagnostic ID: Ruby::FalseAssertion
324
+
325
+ └ hash = array #: Hash[Symbol, String]
326
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327
+ ```
328
+
329
+
330
+ ### Severity
331
+
332
+ | all_error | strict | default | lenient | silent |
333
+ | - | - | - | - | - |
334
+ | error | error | hint | - | - |
335
+
336
+ <a name='Ruby::ImplicitBreakValueMismatch'></a>
337
+ ## Ruby::ImplicitBreakValueMismatch
338
+
339
+ A `break` statement without a value is used to leave from a block that requires non-nil type.
340
+
341
+ ### Ruby code
342
+
343
+ ```ruby
344
+ 123.tap { break }
345
+ ```
346
+
347
+ ### Diagnostic
348
+
349
+ ```
350
+ test.rb:1:10: [error] Breaking without a value may result an error because a value of type `::Integer` is expected
351
+ │ nil <: ::Integer
352
+
353
+ │ Diagnostic ID: Ruby::ImplicitBreakValueMismatch
354
+
355
+ └ 123.tap { break }
356
+ ~~~~~
357
+ ```
358
+
359
+
360
+ ### Severity
361
+
362
+ | all_error | strict | default | lenient | silent |
363
+ | - | - | - | - | - |
364
+ | error | information | hint | - | - |
365
+
366
+ <a name='Ruby::IncompatibleAnnotation'></a>
367
+ ## Ruby::IncompatibleAnnotation
368
+
369
+ Detected a branch local annotation is incompatible with outer context.
370
+
371
+ ### Ruby code
372
+
373
+ ```ruby
374
+ a = [1,2,3]
375
+
376
+ if _ = 1
377
+ # @type var a: String
378
+ a + ""
379
+ end
380
+ ```
381
+
382
+ ### Diagnostic
383
+
384
+ ```
385
+ test.rb:5:2: [error] Type annotation about `a` is incompatible since ::String <: ::Array[::Integer] doesn't hold
386
+ │ ::String <: ::Array[::Integer]
387
+ │ ::Object <: ::Array[::Integer]
388
+ │ ::BasicObject <: ::Array[::Integer]
389
+
390
+ │ Diagnostic ID: Ruby::IncompatibleAnnotation
391
+
392
+ └ a + ""
393
+ ~~~~~~
394
+ ```
395
+
396
+
397
+ ### Severity
398
+
399
+ | all_error | strict | default | lenient | silent |
400
+ | - | - | - | - | - |
401
+ | error | error | hint | - | - |
402
+
403
+ <a name='Ruby::IncompatibleArgumentForwarding'></a>
404
+ ## Ruby::IncompatibleArgumentForwarding
405
+
406
+ Argument forwarding `...` cannot be done safely, because of:
407
+
408
+ 1. The arguments are incompatible, or
409
+ 2. The blocks are incompatible
410
+
411
+ ### RBS
412
+
413
+ ```rbs
414
+ class Foo
415
+ def foo: (*Integer) -> void
416
+
417
+ def bar: (*String) -> void
418
+ end
419
+ ```
420
+
421
+ ### Ruby code
422
+
423
+ ```ruby
424
+ class Foo
425
+ def foo(*args)
426
+ end
427
+
428
+ def bar(...)
429
+ foo(...)
430
+ end
431
+ end
432
+ ```
433
+
434
+ ### Diagnostic
435
+
436
+ ```
437
+ test.rb:8:8: [error] Cannot forward arguments to `foo`:
438
+ │ (*::Integer) <: (*::String)
439
+ │ ::String <: ::Integer
440
+ │ ::Object <: ::Integer
441
+
442
+ │ Diagnostic ID: Ruby::IncompatibleArgumentForwarding
443
+
444
+ └ foo(...)
445
+ ~~~
446
+ ```
447
+
448
+
449
+ ### Severity
450
+
451
+ | all_error | strict | default | lenient | silent |
452
+ | - | - | - | - | - |
453
+ | error | error | warning | information | - |
454
+
455
+ <a name='Ruby::IncompatibleAssignment'></a>
456
+ ## Ruby::IncompatibleAssignment
457
+
458
+ An assignment has a right hand side value that has an incompatible type to the type of the left hand side.
459
+
460
+ ### Ruby code
461
+
462
+ ```ruby
463
+ # @type var x: Integer
464
+ x = "string"
465
+ ```
466
+
467
+ ### Diagnostic
468
+
469
+ ```
470
+ test.rb:2:0: [error] Cannot assign a value of type `::String` to a variable of type `::Integer`
471
+ │ ::String <: ::Integer
472
+ │ ::Object <: ::Integer
473
+ │ ::BasicObject <: ::Integer
474
+
475
+ │ Diagnostic ID: Ruby::IncompatibleAssignment
476
+
477
+ └ x = "string"
478
+ ~~~~~~~~~~~~
479
+ ```
480
+
481
+
482
+ ### Severity
483
+
484
+ | all_error | strict | default | lenient | silent |
485
+ | - | - | - | - | - |
486
+ | error | error | hint | hint | - |
487
+
488
+ <a name='Ruby::InsufficientKeywordArguments'></a>
489
+ ## Ruby::InsufficientKeywordArguments
490
+
491
+ A method call needs more keyword arguments.
492
+
493
+ ### RBS
494
+
495
+ ```rbs
496
+ class Foo
497
+ def foo: (a: untyped, b: untyped) -> void
498
+ end
499
+ ```
500
+
501
+ ### Ruby code
502
+
503
+ ```ruby
504
+ Foo.new.foo(a: 1)
505
+ ```
506
+
507
+ ### Diagnostic
508
+
509
+ ```
510
+ test.rb:5:8: [error] More keyword arguments are required: b
511
+ │ Diagnostic ID: Ruby::InsufficientKeywordArguments
512
+
513
+ └ Foo.new.foo(a: 1)
514
+ ~~~~~~~~~
515
+ ```
516
+
517
+
518
+ ### Severity
519
+
520
+ | all_error | strict | default | lenient | silent |
521
+ | - | - | - | - | - |
522
+ | error | error | error | information | - |
523
+
524
+ <a name='Ruby::InsufficientPositionalArguments'></a>
525
+ ## Ruby::InsufficientPositionalArguments
526
+
527
+ An method call needs more positional arguments.
528
+
529
+ ### RBS
530
+
531
+ ```ruby
532
+ class Foo
533
+ def foo: (a, b) -> void
534
+ end
535
+ ```
536
+
537
+ ### Ruby code
538
+
539
+ ```ruby
540
+ Foo.new.foo(1)
541
+ ```
542
+
543
+ ### Diagnostic
544
+
545
+ ```
546
+ test.rb:1:8: [error] More positional arguments are required
547
+ │ Diagnostic ID: Ruby::InsufficientPositionalArguments
548
+
549
+ └ Foo.new.foo(1)
550
+ ~~~~~~
551
+ ```
552
+
553
+
554
+ ### Severity
555
+
556
+ | all_error | strict | default | lenient | silent |
557
+ | - | - | - | - | - |
558
+ | error | error | error | information | - |
559
+
560
+ <a name='Ruby::InsufficientTypeArgument'></a>
561
+ ## Ruby::InsufficientTypeArgument
562
+
563
+ A type application needs more type arguments.
564
+
565
+ ### RBS
566
+
567
+ ```rbs
568
+ class Foo
569
+ def foo: [T, S] (T, S) -> [T, S]
570
+ end
571
+ ```
572
+
573
+ ### Ruby code
574
+
575
+ ```ruby
576
+ Foo.new.foo(1, 2) #$ Integer
577
+ ```
578
+
579
+ ### Diagnostic
580
+
581
+ ```
582
+ test.rb:8:0: [error] Requires 2 types, but 1 given: `[T, S] (T, S) -> [T, S]`
583
+ │ Diagnostic ID: Ruby::InsufficientTypeArgument
584
+
585
+ └ Foo.new.foo(1, 2) #$ Integer
586
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
587
+ ```
588
+
589
+
590
+ ### Severity
591
+
592
+ | all_error | strict | default | lenient | silent |
593
+ | - | - | - | - | - |
594
+ | error | error | hint | - | - |
595
+
596
+ <a name='Ruby::InvalidIgnoreComment'></a>
597
+ ## Ruby::InvalidIgnoreComment
598
+
599
+ `steep:ignore` comment is invalid.
600
+
601
+ ### Ruby code
602
+
603
+ ```ruby
604
+ # steep:ignore:start
605
+ ```
606
+
607
+ ### Diagnostic
608
+
609
+ ```
610
+ test.rb:1:0: [error] Invalid ignore comment
611
+ │ Diagnostic ID: Ruby::InvalidIgnoreComment
612
+
613
+ └ # steep:ignore:start
614
+ ~~~~~~~~~~~~~~~~~~~~
615
+ ```
616
+
617
+
618
+ ### Severity
619
+
620
+ | all_error | strict | default | lenient | silent |
621
+ | - | - | - | - | - |
622
+ | error | warning | warning | warning | - |
623
+
624
+ <a name='Ruby::MethodArityMismatch'></a>
625
+ ## Ruby::MethodArityMismatch
626
+
627
+ The method definition has missing parameters with respect to the RBS definition.
628
+
629
+ ### RBS
630
+
631
+ ```rbs
632
+ class Foo
633
+ def foo: (String, String) -> void
634
+ end
635
+ ```
636
+
637
+ ### Ruby code
638
+
639
+ ```ruby
640
+ class Foo
641
+ def foo(x)
642
+ end
643
+ end
644
+ ```
645
+
646
+ ### Diagnostic
647
+
648
+ ```
649
+ test.rb:2:9: [error] Method parameters are incompatible with declaration `(::String, ::String) -> void`
650
+ │ Diagnostic ID: Ruby::MethodArityMismatch
651
+
652
+ └ def foo(x)
653
+ ~~~
654
+ ```
655
+
656
+
657
+ ### Severity
658
+
659
+ | all_error | strict | default | lenient | silent |
660
+ | - | - | - | - | - |
661
+ | error | error | error | information | - |
662
+
663
+ <a name='Ruby::MethodBodyTypeMismatch'></a>
664
+ ## Ruby::MethodBodyTypeMismatch
665
+
666
+ The type of the method body has different type from the RBS definition.
667
+
668
+ ### RBS
669
+
670
+ ```rbs
671
+ class Foo
672
+ def foo: () -> String
673
+ end
674
+ ```
675
+
676
+ ### Ruby code
677
+
678
+ ```ruby
679
+ class Foo
680
+ def foo = 123
681
+ end
682
+ ```
683
+
684
+ ### Diagnostic
685
+
686
+ ```
687
+ test.rb:2:6: [error] Cannot allow method body have type `::Integer` because declared as type `::String`
688
+ │ ::Integer <: ::String
689
+ │ ::Numeric <: ::String
690
+ │ ::Object <: ::String
691
+ │ ::BasicObject <: ::String
692
+
693
+ │ Diagnostic ID: Ruby::MethodBodyTypeMismatch
694
+
695
+ └ def foo = 123
696
+ ~~~
697
+ ```
698
+
699
+
700
+ ### Severity
701
+
702
+ | all_error | strict | default | lenient | silent |
703
+ | - | - | - | - | - |
704
+ | error | error | error | warning | - |
705
+
706
+ <a name='Ruby::MethodDefinitionInUndeclaredModule'></a>
707
+ ## Ruby::MethodDefinitionInUndeclaredModule
708
+
709
+ A `def` syntax doesn't have method type because the module/class is undefined in RBS.
710
+
711
+ ### Ruby code
712
+
713
+ ```ruby
714
+ class UndeclaredClass
715
+ def to_s = 123
716
+ end
717
+ ```
718
+
719
+ ### Diagnostic
720
+
721
+ ```
722
+ test.rb:2:6: [error] Method `to_s` is defined in undeclared module
723
+ │ Diagnostic ID: Ruby::MethodDefinitionInUndeclaredModule
724
+
725
+ └ def to_s = 123
726
+ ~~~~
727
+ ```
728
+
729
+
730
+ ### Severity
731
+
732
+ | all_error | strict | default | lenient | silent |
733
+ | - | - | - | - | - |
734
+ | error | warning | information | hint | - |
735
+
736
+ <a name='Ruby::MethodDefinitionMissing'></a>
737
+ ## Ruby::MethodDefinitionMissing
738
+
739
+ The class/module definition doesn't have a `def` syntax for the method.
740
+
741
+ ### RBS
742
+
743
+ ```rbs
744
+ class Foo
745
+ def foo: () -> String
746
+ end
747
+ ```
748
+
749
+ ### Ruby code
750
+
751
+ ```ruby
752
+ class Foo
753
+ attr_reader :foo
754
+ end
755
+ ```
756
+
757
+ ### Diagnostic
758
+
759
+ ```
760
+ test.rb:1:6: [hint] Cannot find implementation of method `::Foo#foo`
761
+ │ Diagnostic ID: Ruby::MethodDefinitionMissing
762
+
763
+ └ class Foo
764
+ ~~~
765
+ ```
766
+
767
+
768
+ ### Severity
769
+
770
+ | all_error | strict | default | lenient | silent |
771
+ | - | - | - | - | - |
772
+ | error | hint | - | - | - |
773
+
774
+ <a name='Ruby::MethodParameterMismatch'></a>
775
+ ## Ruby::MethodParameterMismatch
776
+
777
+ The method definition has an extra parameter with respect to the RBS definition.
778
+
779
+ ### RBS
780
+
781
+ ```rbs
782
+ class Foo
783
+ def foo: (String) -> void
784
+ end
785
+ ```
786
+
787
+ ### Ruby code
788
+
789
+ ```ruby
790
+ class Foo
791
+ def foo(x, y)
792
+ end
793
+ end
794
+ ```
795
+
796
+ ### Diagnostic
797
+
798
+ ```
799
+ test.rb:2:13: [error] The method parameter is incompatible with the declaration `(::String) -> void`
800
+ │ Diagnostic ID: Ruby::MethodParameterMismatch
801
+
802
+ └ def foo(x, y)
803
+ ~
804
+ ```
805
+
806
+
807
+ ### Severity
808
+
809
+ | all_error | strict | default | lenient | silent |
810
+ | - | - | - | - | - |
811
+ | error | error | error | warning | - |
812
+
813
+ <a name='Ruby::MethodReturnTypeAnnotationMismatch'></a>
814
+ ## Ruby::MethodReturnTypeAnnotationMismatch
815
+
816
+ **Deprecated** Related to the `@type method` annotation.
817
+
818
+
819
+ ### Severity
820
+
821
+ | all_error | strict | default | lenient | silent |
822
+ | - | - | - | - | - |
823
+ | error | error | hint | - | - |
824
+
825
+ <a name='Ruby::MultipleAssignmentConversionError'></a>
826
+ ## Ruby::MultipleAssignmentConversionError
827
+
828
+ The `#to_ary` of RHS of multiple assignment is called, but returns not tuple nor Array.
829
+
830
+ ### RBS
831
+
832
+ ```rbs
833
+ class Foo
834
+ def to_ary: () -> Integer
835
+ end
836
+ ```
837
+
838
+ ### Ruby code
839
+
840
+ ```ruby
841
+ a, b = Foo.new()
842
+ ```
843
+
844
+ ### Diagnostic
845
+
846
+ ```
847
+ test.rb:1:6: [error] Cannot convert `::Foo` to Array or tuple (`#to_ary` returns `::Integer`)
848
+ │ Diagnostic ID: Ruby::MultipleAssignmentConversionError
849
+
850
+ └ a,b = Foo.new
851
+ ~~~~~~~
852
+ ```
853
+
854
+
855
+ ### Severity
856
+
857
+ | all_error | strict | default | lenient | silent |
858
+ | - | - | - | - | - |
859
+ | error | error | hint | - | - |
860
+
861
+ <a name='Ruby::NoMethod'></a>
862
+ ## Ruby::NoMethod
863
+
864
+ A method call calls a method that is not defined on the receiver.
865
+
866
+ ### Ruby code
867
+
868
+ ```ruby
869
+ "".non_existent_method
870
+ ```
871
+
872
+ ### Diagnostic
873
+
874
+ ```
875
+ test.rb:1:3: [error] Type `::String` does not have method `non_existent_method`
876
+ │ Diagnostic ID: Ruby::NoMethod
877
+
878
+ └ "".non_existent_method
879
+ ~~~~~~~~~~~~~~~~~~~
880
+ ```
881
+
882
+
883
+ ### Severity
884
+
885
+ | all_error | strict | default | lenient | silent |
886
+ | - | - | - | - | - |
887
+ | error | error | error | information | - |
888
+
889
+ <a name='Ruby::ProcHintIgnored'></a>
890
+ ## Ruby::ProcHintIgnored
891
+
892
+ Type hint is given to a proc/lambda but it was ignored.
893
+
894
+ 1. Because the hint is incompatible to `::Proc` type
895
+ 2. More than one *proc type* is included in the hint
896
+
897
+ ### Ruby code
898
+
899
+ ```ruby
900
+ # @type var proc: (^(::Integer) -> ::String) | (^(::String, ::String) -> ::Integer)
901
+ proc = -> (x) { x.to_s }
902
+ ```
903
+
904
+ ### Diagnostic
905
+
906
+ ```
907
+ test.rb:2:7: [error] The type hint given to the block is ignored: `(^(::Integer) -> ::String | ^(::String, ::String) -> ::Integer)`
908
+ │ Diagnostic ID: Ruby::ProcHintIgnored
909
+
910
+ └ proc = -> (x) { x.to_s }
911
+ ~~~~~~~~~~~~~~~~~
912
+ ```
913
+
914
+
915
+ ### Severity
916
+
917
+ | all_error | strict | default | lenient | silent |
918
+ | - | - | - | - | - |
919
+ | error | information | hint | - | - |
920
+
921
+ <a name='Ruby::ProcTypeExpected'></a>
922
+ ## Ruby::ProcTypeExpected
923
+
924
+ The block parameter has non-proc type.
925
+
926
+ ### Ruby code
927
+
928
+ ```ruby
929
+ -> (&block) do
930
+ # @type var block: Integer
931
+ end
932
+ ```
933
+
934
+ ### Diagnostic
935
+
936
+ ```
937
+ test.rb:1:4: [error] Proc type is expected but `::Integer` is specified
938
+ │ Diagnostic ID: Ruby::ProcTypeExpected
939
+
940
+ └ -> (&block) do
941
+ ~~~~~~
942
+ ```
943
+
944
+
945
+ ### Severity
946
+
947
+ | all_error | strict | default | lenient | silent |
948
+ | - | - | - | - | - |
949
+ | error | error | hint | - | - |
950
+
951
+ <a name='Ruby::RBSError'></a>
952
+ ## Ruby::RBSError
953
+
954
+ RBS embedded in the Ruby code has validation error.
955
+
956
+ ### Ruby code
957
+
958
+ ```ruby
959
+ a = 1 #: Int
960
+ ```
961
+
962
+ ### Diagnostic
963
+
964
+ ```
965
+ test.rb:1:9: [error] Cannot find type `::Int`
966
+ │ Diagnostic ID: Ruby::RBSError
967
+
968
+ └ a = 1 #: Int
969
+ ~~~
970
+ ```
971
+
972
+
973
+ ### Severity
974
+
975
+ | all_error | strict | default | lenient | silent |
976
+ | - | - | - | - | - |
977
+ | error | error | information | information | - |
978
+
979
+ <a name='Ruby::RequiredBlockMissing'></a>
980
+ ## Ruby::RequiredBlockMissing
981
+
982
+ A method that requires a block is called without a block.
983
+
984
+ ### RBS
985
+
986
+ ```rbs
987
+ class Foo
988
+ def foo: { () -> void } -> void
989
+ end
990
+ ```
991
+
992
+ ### Ruby code
993
+
994
+ ```ruby
995
+ Foo.new.foo
996
+ ```
997
+
998
+ ### Diagnostic
999
+
1000
+ ```
1001
+ test.rb:1:8: [error] The method cannot be called without a block
1002
+ │ Diagnostic ID: Ruby::RequiredBlockMissing
1003
+
1004
+ └ Foo.new.foo
1005
+ ~~~
1006
+ ```
1007
+
1008
+
1009
+ ### Severity
1010
+
1011
+ | all_error | strict | default | lenient | silent |
1012
+ | - | - | - | - | - |
1013
+ | error | error | error | hint | - |
1014
+
1015
+ <a name='Ruby::ReturnTypeMismatch'></a>
1016
+ ## Ruby::ReturnTypeMismatch
1017
+
1018
+ A `return` statement has a value that has an incompatible type to the return type of the method.
1019
+
1020
+ ### RBS
1021
+
1022
+ ```rbs
1023
+ class Foo
1024
+ def foo: () -> Integer
1025
+ end
1026
+ ```
1027
+
1028
+ ### Ruby code
1029
+
1030
+ ```ruby
1031
+ class Foo
1032
+ def foo
1033
+ return "string"
1034
+ end
1035
+ end
1036
+ ```
1037
+
1038
+ ### Diagnostic
1039
+
1040
+ ```
1041
+ test.rb:3:2: [error] The method cannot return a value of type `::String` because declared as type `::Integer`
1042
+ │ ::String <: ::Integer
1043
+ │ ::Object <: ::Integer
1044
+ │ ::BasicObject <: ::Integer
1045
+
1046
+ │ Diagnostic ID: Ruby::ReturnTypeMismatch
1047
+
1048
+ └ return "string"
1049
+ ~~~~~~~~~~~~~~~
1050
+ ```
1051
+
1052
+
1053
+ ### Severity
1054
+
1055
+ | all_error | strict | default | lenient | silent |
1056
+ | - | - | - | - | - |
1057
+ | error | error | error | warning | - |
1058
+
1059
+ <a name='Ruby::SetterBodyTypeMismatch'></a>
1060
+ ## Ruby::SetterBodyTypeMismatch
1061
+
1062
+ Setter method, which has a name ending with `=`, has different type from the method type.
1063
+
1064
+ This is a special diagnostic for setter methods because the return value is not used with ordinal call syntax.
1065
+
1066
+ ### RBS
1067
+
1068
+ ### Ruby code
1069
+
1070
+ ```ruby
1071
+ class Foo
1072
+ # Assume `name=` has method type of `(String) -> String`
1073
+ def name=(value)
1074
+ @value = value
1075
+ value.strip!
1076
+ end
1077
+ end
1078
+ ```
1079
+
1080
+ ### Diagnostic
1081
+
1082
+ ```
1083
+ test.rb:2:6: [information] Setter method `name=` cannot have type `(::String | nil)` because declared as type `::String`
1084
+ │ (::String | nil) <: ::String
1085
+ │ nil <: ::String
1086
+
1087
+ │ Diagnostic ID: Ruby::SetterBodyTypeMismatch
1088
+
1089
+ └ def name=(value)
1090
+ ~~~~~
1091
+ ```
1092
+
1093
+
1094
+ ### Severity
1095
+
1096
+ | all_error | strict | default | lenient | silent |
1097
+ | - | - | - | - | - |
1098
+ | error | error | information | - | - |
1099
+
1100
+ <a name='Ruby::SetterReturnTypeMismatch'></a>
1101
+ ## Ruby::SetterReturnTypeMismatch
1102
+
1103
+ Setter method, which has a name ending with `=`, returns different type from the method type.
1104
+ This is a special diagnostic for setter methods because the return value is not used with ordinal call syntax.
1105
+
1106
+ ### RBS
1107
+
1108
+ ```rbs
1109
+ class Foo
1110
+ def name=: (String) -> String
1111
+ end
1112
+ ```
1113
+
1114
+ ### Ruby code
1115
+
1116
+ ```ruby
1117
+ class Foo
1118
+ def name=(value)
1119
+ return if value.empty?
1120
+ @value = value
1121
+ end
1122
+ end
1123
+ ```
1124
+
1125
+ ### Diagnostic
1126
+
1127
+ ```
1128
+ test.rb:3:4: [information] The setter method `name=` cannot return a value of type `nil` because declared as type `::String`
1129
+ │ nil <: ::String
1130
+
1131
+ │ Diagnostic ID: Ruby::SetterReturnTypeMismatch
1132
+
1133
+ └ return if value.empty?
1134
+ ~~~~~~
1135
+ ```
1136
+
1137
+
1138
+ ### Severity
1139
+
1140
+ | all_error | strict | default | lenient | silent |
1141
+ | - | - | - | - | - |
1142
+ | error | error | information | - | - |
1143
+
1144
+ <a name='Ruby::SyntaxError'></a>
1145
+ ## Ruby::SyntaxError
1146
+
1147
+ The Ruby code has a syntax error.
1148
+
1149
+ ### Ruby code
1150
+
1151
+ ```ruby
1152
+ if x == 1
1153
+ puts "Hello"
1154
+ ```
1155
+
1156
+ ### Diagnostic
1157
+
1158
+ ```
1159
+ test.rb:2:14: [error] SyntaxError: unexpected token $end
1160
+ │ Diagnostic ID: Ruby::SyntaxError
1161
+
1162
+ └ puts "Hello"
1163
+ ```
1164
+
1165
+
1166
+ ### Severity
1167
+
1168
+ | all_error | strict | default | lenient | silent |
1169
+ | - | - | - | - | - |
1170
+ | error | information | information | information | - |
1171
+
1172
+ <a name='Ruby::TypeArgumentMismatchError'></a>
1173
+ ## Ruby::TypeArgumentMismatchError
1174
+
1175
+ The type application doesn't satisfy generic constraints.
1176
+
1177
+ ### RBS
1178
+
1179
+ ```rbs
1180
+ class Foo
1181
+ def foo: [T < Numeric] (T) -> T
1182
+ end
1183
+ ```
1184
+
1185
+ ### Ruby code
1186
+
1187
+ ```ruby
1188
+ Foo.new.foo("") #$ String
1189
+ ```
1190
+
1191
+ ### Diagnostic
1192
+
1193
+ ```
1194
+ test.rb:7:19: [error] Cannot pass a type `::String` as a type parameter `T < ::Numeric`
1195
+ │ ::String <: ::Numeric
1196
+ │ ::Object <: ::Numeric
1197
+ │ ::BasicObject <: ::Numeric
1198
+
1199
+ │ Diagnostic ID: Ruby::TypeArgumentMismatchError
1200
+
1201
+ └ Foo.new.foo("") #$ String
1202
+ ~~~~~~
1203
+ ```
1204
+
1205
+
1206
+ ### Severity
1207
+
1208
+ | all_error | strict | default | lenient | silent |
1209
+ | - | - | - | - | - |
1210
+ | error | error | hint | - | - |
1211
+
1212
+ <a name='Ruby::UnannotatedEmptyCollection'></a>
1213
+ ## Ruby::UnannotatedEmptyCollection
1214
+
1215
+ An empty array/hash has no type assertion.
1216
+
1217
+ They are typed as `Array[untyped]` or `Hash[untyped, untyped]`,
1218
+ which allows any element to be added.
1219
+
1220
+ ```rb
1221
+ a = []
1222
+ b = {}
1223
+
1224
+ a << 1
1225
+ a << ""
1226
+ ```
1227
+
1228
+ Add type annotation to make your assumption explicit.
1229
+
1230
+ ```rb
1231
+ a = [] #: Array[Integer]
1232
+ b = {} #: untyped
1233
+
1234
+ a << 1
1235
+ a << "" # => Type error
1236
+ ```
1237
+
1238
+ ### Ruby code
1239
+
1240
+ ```ruby
1241
+ a = []
1242
+ b = {}
1243
+ ```
1244
+
1245
+ ### Diagnostic
1246
+
1247
+ ```
1248
+ test.rb:1:4: [error] Empty array doesn't have type annotation
1249
+ │ Diagnostic ID: Ruby::UnannotatedEmptyCollection
1250
+
1251
+ └ a = []
1252
+ ~~
1253
+
1254
+ test.rb:2:4: [error] Empty hash doesn't have type annotation
1255
+ │ Diagnostic ID: Ruby::UnannotatedEmptyCollection
1256
+
1257
+ └ b = {}
1258
+ ~~
1259
+ ```
1260
+
1261
+
1262
+ ### Severity
1263
+
1264
+ | all_error | strict | default | lenient | silent |
1265
+ | - | - | - | - | - |
1266
+ | error | error | warning | hint | - |
1267
+
1268
+ <a name='Ruby::UndeclaredMethodDefinition'></a>
1269
+ ## Ruby::UndeclaredMethodDefinition
1270
+
1271
+ A `def` syntax doesn't have corresponding RBS method definition.
1272
+
1273
+ ### RBS
1274
+
1275
+ ```rbs
1276
+ class Foo
1277
+ end
1278
+ ```
1279
+
1280
+ ### Ruby code
1281
+
1282
+ ```ruby
1283
+ class Foo
1284
+ def undeclared = nil
1285
+ end
1286
+ ```
1287
+
1288
+ ### Diagnostic
1289
+
1290
+ ```
1291
+ test.rb:2:6: [error] Method `::Foo#undeclared` is not declared in RBS
1292
+ │ Diagnostic ID: Ruby::UndeclaredMethodDefinition
1293
+
1294
+ └ def undeclared = nil
1295
+ ~~~~~~~~~~
1296
+ ```
1297
+
1298
+
1299
+ ### Severity
1300
+
1301
+ | all_error | strict | default | lenient | silent |
1302
+ | - | - | - | - | - |
1303
+ | error | warning | warning | information | - |
1304
+
1305
+ <a name='Ruby::UnexpectedBlockGiven'></a>
1306
+ ## Ruby::UnexpectedBlockGiven
1307
+
1308
+ A method that doesn't accept block is called with a block.
1309
+
1310
+ ### RBS
1311
+
1312
+ ```rbs
1313
+ class Foo
1314
+ def foo: () -> void
1315
+ end
1316
+ ```
1317
+
1318
+ ### Ruby code
1319
+
1320
+ ```ruby
1321
+ Foo.new.foo { 123 }
1322
+ ```
1323
+
1324
+ ### Diagnostic
1325
+
1326
+ ```
1327
+ test.rb:1:12: [warning] The method cannot be called with a block
1328
+ │ Diagnostic ID: Ruby::UnexpectedBlockGiven
1329
+
1330
+ └ Foo.new.foo { 123 }
1331
+ ~~~~~~~
1332
+ ```
1333
+
1334
+
1335
+ ### Severity
1336
+
1337
+ | all_error | strict | default | lenient | silent |
1338
+ | - | - | - | - | - |
1339
+ | error | error | warning | hint | - |
1340
+
1341
+ <a name='Ruby::UnexpectedDynamicMethod'></a>
1342
+ ## Ruby::UnexpectedDynamicMethod
1343
+
1344
+ A `@dynamic` annotation has unknown method name.
1345
+
1346
+ Note that this diagnostic emits only if the class definition in RBS has method definitions.
1347
+
1348
+ ### RBS
1349
+
1350
+ ```rbs
1351
+ class Foo
1352
+ def foo: () -> void
1353
+ end
1354
+ ```
1355
+
1356
+ ### Ruby code
1357
+
1358
+ ```ruby
1359
+ class Foo
1360
+ # @dynamic foo, bar
1361
+ end
1362
+ ```
1363
+
1364
+ ### Diagnostic
1365
+
1366
+ ```
1367
+ test.rb:1:6: [error] @dynamic annotation contains unknown method name `bar`
1368
+ │ Diagnostic ID: Ruby::UnexpectedDynamicMethod
1369
+
1370
+ └ class Foo
1371
+ ~~~
1372
+ ```
1373
+
1374
+
1375
+ ### Severity
1376
+
1377
+ | all_error | strict | default | lenient | silent |
1378
+ | - | - | - | - | - |
1379
+ | error | information | hint | - | - |
1380
+
1381
+ <a name='Ruby::UnexpectedError'></a>
1382
+ ## Ruby::UnexpectedError
1383
+
1384
+ Unexpected error is raised during type checking. Maybe a bug.
1385
+
1386
+
1387
+ ### Severity
1388
+
1389
+ | all_error | strict | default | lenient | silent |
1390
+ | - | - | - | - | - |
1391
+ | error | information | hint | hint | - |
1392
+
1393
+ <a name='Ruby::UnexpectedJump'></a>
1394
+ ## Ruby::UnexpectedJump
1395
+
1396
+ Detected a `break` or `next` statement in invalid context.
1397
+
1398
+ ### Ruby code
1399
+
1400
+ ```ruby
1401
+ break
1402
+ ```
1403
+
1404
+ ### Diagnostic
1405
+
1406
+ ```
1407
+ test.rb:1:0: [error] Cannot jump from here
1408
+ │ Diagnostic ID: Ruby::UnexpectedJump
1409
+
1410
+ └ break
1411
+ ~~~~~
1412
+ ```
1413
+
1414
+
1415
+ ### Severity
1416
+
1417
+ | all_error | strict | default | lenient | silent |
1418
+ | - | - | - | - | - |
1419
+ | error | error | hint | - | - |
1420
+
1421
+ <a name='Ruby::UnexpectedJumpValue'></a>
1422
+ ## Ruby::UnexpectedJumpValue
1423
+
1424
+ A `break` or `next` statement has a value, but the value will be ignored.
1425
+
1426
+ ### Ruby code
1427
+
1428
+ ```ruby
1429
+ while true
1430
+ next 3
1431
+ end
1432
+ ```
1433
+
1434
+ ### Diagnostic
1435
+
1436
+ ```
1437
+ test.rb:2:2: [error] The value given to next will be ignored
1438
+ │ Diagnostic ID: Ruby::UnexpectedJumpValue
1439
+
1440
+ └ next 3
1441
+ ~~~~~~
1442
+ ```
1443
+
1444
+
1445
+ ### Severity
1446
+
1447
+ | all_error | strict | default | lenient | silent |
1448
+ | - | - | - | - | - |
1449
+ | error | error | hint | - | - |
1450
+
1451
+ <a name='Ruby::UnexpectedKeywordArgument'></a>
1452
+ ## Ruby::UnexpectedKeywordArgument
1453
+
1454
+ A method call has an extra keyword argument.
1455
+
1456
+ ### RBS
1457
+
1458
+ ```rbs
1459
+ class Foo
1460
+ def foo: (x: untyped) -> void
1461
+ end
1462
+ ```
1463
+
1464
+ ### Ruby code
1465
+
1466
+ ```ruby
1467
+ Foo.new.foo(x: 1, y: 2)
1468
+ ```
1469
+
1470
+ ### Diagnostic
1471
+
1472
+ ```
1473
+ test.rb:7:18: [error] Unexpected keyword argument
1474
+ │ Diagnostic ID: Ruby::UnexpectedKeywordArgument
1475
+
1476
+ └ Foo.new.foo(x: 1, y: 2)
1477
+ ~
1478
+ ```
1479
+
1480
+
1481
+ ### Severity
1482
+
1483
+ | all_error | strict | default | lenient | silent |
1484
+ | - | - | - | - | - |
1485
+ | error | error | error | information | - |
1486
+
1487
+ <a name='Ruby::UnexpectedPositionalArgument'></a>
1488
+ ## Ruby::UnexpectedPositionalArgument
1489
+
1490
+ A method call has an extra positional argument.
1491
+
1492
+ ### RBS
1493
+
1494
+ ```rbs
1495
+ class Foo
1496
+ def foo: (untyped) -> void
1497
+ end
1498
+ ```
1499
+
1500
+ ### Ruby code
1501
+
1502
+ ```ruby
1503
+ Foo.new.foo(1, 2)
1504
+ ```
1505
+
1506
+ ### Diagnostic
1507
+
1508
+ ```
1509
+ test.rb:7:15: [error] Unexpected positional argument
1510
+ │ Diagnostic ID: Ruby::UnexpectedPositionalArgument
1511
+
1512
+ └ Foo.new.foo(1, 2)
1513
+ ~
1514
+ ```
1515
+
1516
+
1517
+ ### Severity
1518
+
1519
+ | all_error | strict | default | lenient | silent |
1520
+ | - | - | - | - | - |
1521
+ | error | error | error | information | - |
1522
+
1523
+ <a name='Ruby::UnexpectedSuper'></a>
1524
+ ## Ruby::UnexpectedSuper
1525
+
1526
+ A method definition has `super` syntax while no super method is defined in RBS.
1527
+
1528
+ ### RBS
1529
+
1530
+ ```rbs
1531
+ class Foo
1532
+ def foo: () -> void
1533
+ end
1534
+ ```
1535
+
1536
+ ### Ruby code
1537
+
1538
+ ```ruby
1539
+ class Foo
1540
+ def foo = super
1541
+ end
1542
+ ```
1543
+
1544
+ ### Diagnostic
1545
+
1546
+ ```
1547
+ test.rb:2:12: [information] No superclass method `foo` defined
1548
+ │ Diagnostic ID: Ruby::UnexpectedSuper
1549
+
1550
+ └ def foo = super
1551
+ ~~~~~
1552
+ ```
1553
+
1554
+
1555
+ ### Severity
1556
+
1557
+ | all_error | strict | default | lenient | silent |
1558
+ | - | - | - | - | - |
1559
+ | error | error | information | - | - |
1560
+
1561
+ <a name='Ruby::UnexpectedTypeArgument'></a>
1562
+ ## Ruby::UnexpectedTypeArgument
1563
+
1564
+ An extra type application is given to a method call.
1565
+
1566
+ ### RBS
1567
+
1568
+ ```rbs
1569
+ class Foo
1570
+ def foo: [T] (T) -> T
1571
+ end
1572
+ ```
1573
+
1574
+ ### Ruby code
1575
+
1576
+ ```ruby
1577
+ Foo.new.foo(1) #$ Integer, Integer
1578
+ ```
1579
+
1580
+ ### Diagnostic
1581
+
1582
+ ```
1583
+ test.rb:8:27: [error] Unexpected type arg is given to method type `[T] (T) -> T`
1584
+ │ Diagnostic ID: Ruby::UnexpectedTypeArgument
1585
+
1586
+ └ Foo.new.foo(1) #$ Integer, Integer
1587
+ ~~~~~~~
1588
+ ```
1589
+
1590
+
1591
+ ### Severity
1592
+
1593
+ | all_error | strict | default | lenient | silent |
1594
+ | - | - | - | - | - |
1595
+ | error | error | hint | - | - |
1596
+
1597
+ <a name='Ruby::UnexpectedYield'></a>
1598
+ ## Ruby::UnexpectedYield
1599
+
1600
+ A method definition without block has `yield` syntax.
1601
+
1602
+ ### RBS
1603
+
1604
+ ```rbs
1605
+ class Foo
1606
+ def foo: () -> void
1607
+ end
1608
+ ```
1609
+
1610
+ ### Ruby code
1611
+
1612
+ ```ruby
1613
+ class Foo
1614
+ def foo
1615
+ yield
1616
+ end
1617
+ end
1618
+ ```
1619
+
1620
+ ### Diagnostic
1621
+
1622
+ ```
1623
+ test.rb:3:4: [hint] Cannot detect the type of the expression
1624
+ │ Diagnostic ID: Ruby::FallbackAny
1625
+
1626
+ └ yield
1627
+ ~~~~~
1628
+ ```
1629
+
1630
+
1631
+ ### Severity
1632
+
1633
+ | all_error | strict | default | lenient | silent |
1634
+ | - | - | - | - | - |
1635
+ | error | error | warning | information | - |
1636
+
1637
+ <a name='Ruby::UnknownConstant'></a>
1638
+ ## Ruby::UnknownConstant
1639
+
1640
+ A constant is not defined in the RBS definition.
1641
+
1642
+ ### Ruby code
1643
+
1644
+ ```ruby
1645
+ FOO
1646
+ ```
1647
+
1648
+ ### Diagnostic
1649
+
1650
+ ```
1651
+ test.rb:1:0: [error] Cannot find the declaration of constant: `FOO`
1652
+ │ Diagnostic ID: Ruby::UnknownConstant
1653
+
1654
+ └ FOO
1655
+ ~~~
1656
+ ```
1657
+
1658
+
1659
+ ### Severity
1660
+
1661
+ | all_error | strict | default | lenient | silent |
1662
+ | - | - | - | - | - |
1663
+ | error | error | warning | hint | - |
1664
+
1665
+ <a name='Ruby::UnknownGlobalVariable'></a>
1666
+ ## Ruby::UnknownGlobalVariable
1667
+
1668
+ Short explanation ending with `.`
1669
+
1670
+ ### Ruby code
1671
+
1672
+ ```ruby
1673
+ $foo
1674
+ ```
1675
+
1676
+ ### Diagnostic
1677
+
1678
+ ```
1679
+ test.rb:1:0: [error] Cannot find the declaration of global variable: `$foo`
1680
+ │ Diagnostic ID: Ruby::UnknownGlobalVariable
1681
+
1682
+ └ $foo
1683
+ ~~~~
1684
+ ```
1685
+
1686
+
1687
+ ### Severity
1688
+
1689
+ | all_error | strict | default | lenient | silent |
1690
+ | - | - | - | - | - |
1691
+ | error | error | warning | hint | - |
1692
+
1693
+ <a name='Ruby::UnknownInstanceVariable'></a>
1694
+ ## Ruby::UnknownInstanceVariable
1695
+
1696
+ An instance variable is not defined in RBS definition.
1697
+
1698
+ ### Ruby code
1699
+
1700
+ ```ruby
1701
+ class Foo
1702
+ def foo
1703
+ @foo = 'foo'
1704
+ end
1705
+ end
1706
+ ```
1707
+
1708
+ ### Diagnostic
1709
+
1710
+ ```
1711
+ test.rb:3:4: [error] Cannot find the declaration of instance variable: `@foo`
1712
+ │ Diagnostic ID: Ruby::UnknownInstanceVariable
1713
+
1714
+ └ @foo = 'foo'
1715
+ ~~~~
1716
+ ```
1717
+
1718
+
1719
+ ### Severity
1720
+
1721
+ | all_error | strict | default | lenient | silent |
1722
+ | - | - | - | - | - |
1723
+ | error | error | information | hint | - |
1724
+
1725
+ <a name='Ruby::UnknownRecordKey'></a>
1726
+ ## Ruby::UnknownRecordKey
1727
+
1728
+ An unknown key is given to record type.
1729
+
1730
+ ### Ruby code
1731
+
1732
+ ```ruby
1733
+ { name: "soutaro", email: "soutaro@example.com" } #: { name: String }
1734
+ ```
1735
+
1736
+ ### Diagnostic
1737
+
1738
+ ```
1739
+ test.rb:1:19: [error] Unknown key `:email` is given to a record type
1740
+ │ Diagnostic ID: Ruby::UnknownRecordKey
1741
+
1742
+ └ { name: "soutaro", email: "soutaro@example.com" } #: { name: String }
1743
+ ~~~~~
1744
+ ```
1745
+
1746
+
1747
+ ### Severity
1748
+
1749
+ | all_error | strict | default | lenient | silent |
1750
+ | - | - | - | - | - |
1751
+ | error | warning | information | hint | - |
1752
+
1753
+ <a name='Ruby::UnreachableBranch'></a>
1754
+ ## Ruby::UnreachableBranch
1755
+
1756
+ A conditional always/never hold.
1757
+
1758
+ ### Ruby code
1759
+
1760
+ ```ruby
1761
+ if false
1762
+ 1
1763
+ end
1764
+ ```
1765
+
1766
+ ### Diagnostic
1767
+
1768
+ ```
1769
+ test.rb:1:0: [error] The branch is unreachable
1770
+ │ Diagnostic ID: Ruby::UnreachableBranch
1771
+
1772
+ └ if false
1773
+ ~~
1774
+ ```
1775
+
1776
+
1777
+ ### Severity
1778
+
1779
+ | all_error | strict | default | lenient | silent |
1780
+ | - | - | - | - | - |
1781
+ | error | information | hint | hint | - |
1782
+
1783
+ <a name='Ruby::UnreachableValueBranch'></a>
1784
+ ## Ruby::UnreachableValueBranch
1785
+
1786
+ A branch has a type other than `bot`, but unreachable.
1787
+
1788
+ This diagnostic skips the `bot` branch because we often have `else` branch to make the code defensive.
1789
+
1790
+ ### Ruby code
1791
+
1792
+ ```ruby
1793
+ x = 1
1794
+
1795
+ case x
1796
+ when Integer
1797
+ "one"
1798
+ when String
1799
+ "two"
1800
+ when Symbol
1801
+ raise "Unexpected value"
1802
+ end
1803
+ ```
1804
+
1805
+ ### Diagnostic
1806
+
1807
+ ```
1808
+ test.rb:5:0: [error] The branch may evaluate to a value of `::String` but unreachable
1809
+ │ Diagnostic ID: Ruby::UnreachableValueBranch
1810
+
1811
+ └ when String
1812
+ ~~~~
1813
+ ```
1814
+
1815
+
1816
+ ### Severity
1817
+
1818
+ | all_error | strict | default | lenient | silent |
1819
+ | - | - | - | - | - |
1820
+ | error | warning | hint | hint | - |
1821
+
1822
+ <a name='Ruby::UnresolvedOverloading'></a>
1823
+ ## Ruby::UnresolvedOverloading
1824
+
1825
+ A method call has type errors, no more specific explanation cannot be reported.
1826
+
1827
+ ### Ruby code
1828
+
1829
+ ```ruby
1830
+ 3 + "foo"
1831
+ ```
1832
+
1833
+ ### Diagnostic
1834
+
1835
+ ```
1836
+ test.rb:1:0: [error] Cannot find compatible overloading of method `+` of type `::Integer`
1837
+ │ Method types:
1838
+ │ def +: (::Integer) -> ::Integer
1839
+ │ | (::Float) -> ::Float
1840
+ │ | (::Rational) -> ::Rational
1841
+ │ | (::Complex) -> ::Complex
1842
+
1843
+ │ Diagnostic ID: Ruby::UnresolvedOverloading
1844
+
1845
+ └ 3 + "foo"
1846
+ ~~~~~~~~~
1847
+ ```
1848
+
1849
+
1850
+ ### Severity
1851
+
1852
+ | all_error | strict | default | lenient | silent |
1853
+ | - | - | - | - | - |
1854
+ | error | error | error | information | - |
1855
+
1856
+ <a name='Ruby::UnsatisfiableConstraint'></a>
1857
+ ## Ruby::UnsatisfiableConstraint
1858
+
1859
+ Failed to solve constraint collected from a method call typing.
1860
+
1861
+
1862
+ ### Severity
1863
+
1864
+ | all_error | strict | default | lenient | silent |
1865
+ | - | - | - | - | - |
1866
+ | error | error | hint | hint | - |
1867
+
1868
+ <a name='Ruby::UnsupportedSyntax'></a>
1869
+ ## Ruby::UnsupportedSyntax
1870
+
1871
+ The syntax is not currently supported by Steep.
1872
+
1873
+
1874
+ ### Severity
1875
+
1876
+ | all_error | strict | default | lenient | silent |
1877
+ | - | - | - | - | - |
1878
+ | error | information | hint | hint | - |
1879
+