steep 1.9.0.dev.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +76 -0
  3. data/README.md +9 -4
  4. data/Rakefile +1 -0
  5. data/Steepfile +11 -0
  6. data/bin/generate-diagnostics-docs.rb +112 -0
  7. data/lib/steep/ast/builtin.rb +1 -0
  8. data/lib/steep/ast/ignore.rb +1 -1
  9. data/lib/steep/ast/types/factory.rb +2 -0
  10. data/lib/steep/cli.rb +9 -2
  11. data/lib/steep/diagnostic/lsp_formatter.rb +8 -1
  12. data/lib/steep/diagnostic/ruby.rb +65 -3
  13. data/lib/steep/diagnostic/signature.rb +4 -4
  14. data/lib/steep/drivers/check.rb +3 -3
  15. data/lib/steep/drivers/diagnostic_printer.rb +1 -1
  16. data/lib/steep/drivers/init.rb +6 -3
  17. data/lib/steep/expectations.rb +1 -1
  18. data/lib/steep/interface/builder.rb +2 -3
  19. data/lib/steep/interface/function.rb +13 -0
  20. data/lib/steep/interface/method_type.rb +5 -0
  21. data/lib/steep/interface/shape.rb +1 -1
  22. data/lib/steep/project/dsl.rb +2 -0
  23. data/lib/steep/server/change_buffer.rb +1 -1
  24. data/lib/steep/server/interaction_worker.rb +5 -5
  25. data/lib/steep/server/master.rb +2 -17
  26. data/lib/steep/server/type_check_controller.rb +2 -2
  27. data/lib/steep/server/type_check_worker.rb +1 -1
  28. data/lib/steep/services/completion_provider.rb +4 -4
  29. data/lib/steep/services/goto_service.rb +3 -3
  30. data/lib/steep/services/hover_provider/rbs.rb +1 -1
  31. data/lib/steep/services/hover_provider/ruby.rb +6 -6
  32. data/lib/steep/services/signature_help_provider.rb +8 -8
  33. data/lib/steep/services/type_check_service.rb +8 -8
  34. data/lib/steep/signature/validator.rb +3 -3
  35. data/lib/steep/source.rb +4 -4
  36. data/lib/steep/subtyping/check.rb +3 -3
  37. data/lib/steep/subtyping/constraints.rb +4 -4
  38. data/lib/steep/type_construction.rb +84 -45
  39. data/lib/steep/type_inference/block_params.rb +3 -3
  40. data/lib/steep/type_inference/context.rb +1 -1
  41. data/lib/steep/type_inference/method_params.rb +1 -1
  42. data/lib/steep/type_inference/type_env.rb +3 -3
  43. data/lib/steep/version.rb +1 -1
  44. data/manual/annotations.md +37 -0
  45. data/manual/ignore.md +20 -0
  46. data/manual/ruby-diagnostics.md +1812 -0
  47. data/steep.gemspec +1 -1
  48. metadata +8 -5
@@ -0,0 +1,1812 @@
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::MethodDefinitionMissing'></a>
707
+ ## Ruby::MethodDefinitionMissing
708
+
709
+ The class/module definition doesn't have a `def` syntax for the method.
710
+
711
+ ### RBS
712
+
713
+ ```rbs
714
+ class Foo
715
+ def foo: () -> String
716
+ end
717
+ ```
718
+
719
+ ### Ruby code
720
+
721
+ ```ruby
722
+ class Foo
723
+ attr_reader :foo
724
+ end
725
+ ```
726
+
727
+ ### Diagnostic
728
+
729
+ ```
730
+ test.rb:1:6: [hint] Cannot find implementation of method `::Foo#foo`
731
+ │ Diagnostic ID: Ruby::MethodDefinitionMissing
732
+
733
+ └ class Foo
734
+ ~~~
735
+ ```
736
+
737
+
738
+ ### Severity
739
+
740
+ | all_error | strict | default | lenient | silent |
741
+ | - | - | - | - | - |
742
+ | error | hint | - | - | - |
743
+
744
+ <a name='Ruby::MethodParameterMismatch'></a>
745
+ ## Ruby::MethodParameterMismatch
746
+
747
+ The method definition has an extra parameter with respect to the RBS definition.
748
+
749
+ ### RBS
750
+
751
+ ```rbs
752
+ class Foo
753
+ def foo: (String) -> void
754
+ end
755
+ ```
756
+
757
+ ### Ruby code
758
+
759
+ ```ruby
760
+ class Foo
761
+ def foo(x, y)
762
+ end
763
+ end
764
+ ```
765
+
766
+ ### Diagnostic
767
+
768
+ ```
769
+ test.rb:2:13: [error] The method parameter is incompatible with the declaration `(::String) -> void`
770
+ │ Diagnostic ID: Ruby::MethodParameterMismatch
771
+
772
+ └ def foo(x, y)
773
+ ~
774
+ ```
775
+
776
+
777
+ ### Severity
778
+
779
+ | all_error | strict | default | lenient | silent |
780
+ | - | - | - | - | - |
781
+ | error | error | error | warning | - |
782
+
783
+ <a name='Ruby::MethodReturnTypeAnnotationMismatch'></a>
784
+ ## Ruby::MethodReturnTypeAnnotationMismatch
785
+
786
+ **Deprecated** Related to the `@type method` annotation.
787
+
788
+
789
+ ### Severity
790
+
791
+ | all_error | strict | default | lenient | silent |
792
+ | - | - | - | - | - |
793
+ | error | error | hint | - | - |
794
+
795
+ <a name='Ruby::MultipleAssignmentConversionError'></a>
796
+ ## Ruby::MultipleAssignmentConversionError
797
+
798
+ The `#to_ary` of RHS of multiple assignment is called, but returns not tuple nor Array.
799
+
800
+ ### RBS
801
+
802
+ ```rbs
803
+ class Foo
804
+ def to_ary: () -> Integer
805
+ end
806
+ ```
807
+
808
+ ### Ruby code
809
+
810
+ ```ruby
811
+ a, b = Foo.new()
812
+ ```
813
+
814
+ ### Diagnostic
815
+
816
+ ```
817
+ test.rb:1:6: [error] Cannot convert `::Foo` to Array or tuple (`#to_ary` returns `::Integer`)
818
+ │ Diagnostic ID: Ruby::MultipleAssignmentConversionError
819
+
820
+ └ a,b = Foo.new
821
+ ~~~~~~~
822
+ ```
823
+
824
+
825
+ ### Severity
826
+
827
+ | all_error | strict | default | lenient | silent |
828
+ | - | - | - | - | - |
829
+ | error | error | hint | - | - |
830
+
831
+ <a name='Ruby::NoMethod'></a>
832
+ ## Ruby::NoMethod
833
+
834
+ A method call calls a method that is not defined on the receiver.
835
+
836
+ ### Ruby code
837
+
838
+ ```ruby
839
+ "".non_existent_method
840
+ ```
841
+
842
+ ### Diagnostic
843
+
844
+ ```
845
+ test.rb:1:3: [error] Type `::String` does not have method `non_existent_method`
846
+ │ Diagnostic ID: Ruby::NoMethod
847
+
848
+ └ "".non_existent_method
849
+ ~~~~~~~~~~~~~~~~~~~
850
+ ```
851
+
852
+
853
+ ### Severity
854
+
855
+ | all_error | strict | default | lenient | silent |
856
+ | - | - | - | - | - |
857
+ | error | error | error | information | - |
858
+
859
+ <a name='Ruby::ProcHintIgnored'></a>
860
+ ## Ruby::ProcHintIgnored
861
+
862
+ Type hint is given to a proc/lambda but it was ignored.
863
+
864
+ 1. Because the hint is incompatible to `::Proc` type
865
+ 2. More than one *proc type* is included in the hint
866
+
867
+ ### Ruby code
868
+
869
+ ```ruby
870
+ # @type var proc: (^(::Integer) -> ::String) | (^(::String, ::String) -> ::Integer)
871
+ proc = -> (x) { x.to_s }
872
+ ```
873
+
874
+ ### Diagnostic
875
+
876
+ ```
877
+ test.rb:2:7: [error] The type hint given to the block is ignored: `(^(::Integer) -> ::String | ^(::String, ::String) -> ::Integer)`
878
+ │ Diagnostic ID: Ruby::ProcHintIgnored
879
+
880
+ └ proc = -> (x) { x.to_s }
881
+ ~~~~~~~~~~~~~~~~~
882
+ ```
883
+
884
+
885
+ ### Severity
886
+
887
+ | all_error | strict | default | lenient | silent |
888
+ | - | - | - | - | - |
889
+ | error | information | hint | - | - |
890
+
891
+ <a name='Ruby::ProcTypeExpected'></a>
892
+ ## Ruby::ProcTypeExpected
893
+
894
+ The block parameter has non-proc type.
895
+
896
+ ### Ruby code
897
+
898
+ ```ruby
899
+ -> (&block) do
900
+ # @type var block: Integer
901
+ end
902
+ ```
903
+
904
+ ### Diagnostic
905
+
906
+ ```
907
+ test.rb:1:4: [error] Proc type is expected but `::Integer` is specified
908
+ │ Diagnostic ID: Ruby::ProcTypeExpected
909
+
910
+ └ -> (&block) do
911
+ ~~~~~~
912
+ ```
913
+
914
+
915
+ ### Severity
916
+
917
+ | all_error | strict | default | lenient | silent |
918
+ | - | - | - | - | - |
919
+ | error | error | hint | - | - |
920
+
921
+ <a name='Ruby::RBSError'></a>
922
+ ## Ruby::RBSError
923
+
924
+ RBS embedded in the Ruby code has validation error.
925
+
926
+ ### Ruby code
927
+
928
+ ```ruby
929
+ a = 1 #: Int
930
+ ```
931
+
932
+ ### Diagnostic
933
+
934
+ ```
935
+ test.rb:1:9: [error] Cannot find type `::Int`
936
+ │ Diagnostic ID: Ruby::RBSError
937
+
938
+ └ a = 1 #: Int
939
+ ~~~
940
+ ```
941
+
942
+
943
+ ### Severity
944
+
945
+ | all_error | strict | default | lenient | silent |
946
+ | - | - | - | - | - |
947
+ | error | error | information | information | - |
948
+
949
+ <a name='Ruby::RequiredBlockMissing'></a>
950
+ ## Ruby::RequiredBlockMissing
951
+
952
+ A method that requires a block is called without a block.
953
+
954
+ ### RBS
955
+
956
+ ```rbs
957
+ class Foo
958
+ def foo: { () -> void } -> void
959
+ end
960
+ ```
961
+
962
+ ### Ruby code
963
+
964
+ ```ruby
965
+ Foo.new.foo
966
+ ```
967
+
968
+ ### Diagnostic
969
+
970
+ ```
971
+ test.rb:1:8: [error] The method cannot be called without a block
972
+ │ Diagnostic ID: Ruby::RequiredBlockMissing
973
+
974
+ └ Foo.new.foo
975
+ ~~~
976
+ ```
977
+
978
+
979
+ ### Severity
980
+
981
+ | all_error | strict | default | lenient | silent |
982
+ | - | - | - | - | - |
983
+ | error | error | error | hint | - |
984
+
985
+ <a name='Ruby::ReturnTypeMismatch'></a>
986
+ ## Ruby::ReturnTypeMismatch
987
+
988
+ A `return` statement has a value that has an incompatible type to the return type of the method.
989
+
990
+ ### RBS
991
+
992
+ ```rbs
993
+ class Foo
994
+ def foo: () -> Integer
995
+ end
996
+ ```
997
+
998
+ ### Ruby code
999
+
1000
+ ```ruby
1001
+ class Foo
1002
+ def foo
1003
+ return "string"
1004
+ end
1005
+ end
1006
+ ```
1007
+
1008
+ ### Diagnostic
1009
+
1010
+ ```
1011
+ test.rb:3:2: [error] The method cannot return a value of type `::String` because declared as type `::Integer`
1012
+ │ ::String <: ::Integer
1013
+ │ ::Object <: ::Integer
1014
+ │ ::BasicObject <: ::Integer
1015
+
1016
+ │ Diagnostic ID: Ruby::ReturnTypeMismatch
1017
+
1018
+ └ return "string"
1019
+ ~~~~~~~~~~~~~~~
1020
+ ```
1021
+
1022
+
1023
+ ### Severity
1024
+
1025
+ | all_error | strict | default | lenient | silent |
1026
+ | - | - | - | - | - |
1027
+ | error | error | error | warning | - |
1028
+
1029
+ <a name='Ruby::SetterBodyTypeMismatch'></a>
1030
+ ## Ruby::SetterBodyTypeMismatch
1031
+
1032
+ Setter method, which has a name ending with `=`, has different type from the method type.
1033
+
1034
+ This is a special diagnostic for setter methods because the return value is not used with ordinal call syntax.
1035
+
1036
+ ### RBS
1037
+
1038
+ ### Ruby code
1039
+
1040
+ ```ruby
1041
+ class Foo
1042
+ # Assume `name=` has method type of `(String) -> String`
1043
+ def name=(value)
1044
+ @value = value
1045
+ value.strip!
1046
+ end
1047
+ end
1048
+ ```
1049
+
1050
+ ### Diagnostic
1051
+
1052
+ ```
1053
+ test.rb:2:6: [information] Setter method `name=` cannot have type `(::String | nil)` because declared as type `::String`
1054
+ │ (::String | nil) <: ::String
1055
+ │ nil <: ::String
1056
+
1057
+ │ Diagnostic ID: Ruby::SetterBodyTypeMismatch
1058
+
1059
+ └ def name=(value)
1060
+ ~~~~~
1061
+ ```
1062
+
1063
+
1064
+ ### Severity
1065
+
1066
+ | all_error | strict | default | lenient | silent |
1067
+ | - | - | - | - | - |
1068
+ | error | error | information | - | - |
1069
+
1070
+ <a name='Ruby::SetterReturnTypeMismatch'></a>
1071
+ ## Ruby::SetterReturnTypeMismatch
1072
+
1073
+ Setter method, which has a name ending with `=`, returns different type from the method type.
1074
+ This is a special diagnostic for setter methods because the return value is not used with ordinal call syntax.
1075
+
1076
+ ### RBS
1077
+
1078
+ ```rbs
1079
+ class Foo
1080
+ def name=: (String) -> String
1081
+ end
1082
+ ```
1083
+
1084
+ ### Ruby code
1085
+
1086
+ ```ruby
1087
+ class Foo
1088
+ def name=(value)
1089
+ return if value.empty?
1090
+ @value = value
1091
+ end
1092
+ end
1093
+ ```
1094
+
1095
+ ### Diagnostic
1096
+
1097
+ ```
1098
+ test.rb:3:4: [information] The setter method `name=` cannot return a value of type `nil` because declared as type `::String`
1099
+ │ nil <: ::String
1100
+
1101
+ │ Diagnostic ID: Ruby::SetterReturnTypeMismatch
1102
+
1103
+ └ return if value.empty?
1104
+ ~~~~~~
1105
+ ```
1106
+
1107
+
1108
+ ### Severity
1109
+
1110
+ | all_error | strict | default | lenient | silent |
1111
+ | - | - | - | - | - |
1112
+ | error | error | information | - | - |
1113
+
1114
+ <a name='Ruby::SyntaxError'></a>
1115
+ ## Ruby::SyntaxError
1116
+
1117
+ The Ruby code has a syntax error.
1118
+
1119
+ ### Ruby code
1120
+
1121
+ ```ruby
1122
+ if x == 1
1123
+ puts "Hello"
1124
+ ```
1125
+
1126
+ ### Diagnostic
1127
+
1128
+ ```
1129
+ test.rb:2:14: [error] SyntaxError: unexpected token $end
1130
+ │ Diagnostic ID: Ruby::SyntaxError
1131
+
1132
+ └ puts "Hello"
1133
+ ```
1134
+
1135
+
1136
+ ### Severity
1137
+
1138
+ | all_error | strict | default | lenient | silent |
1139
+ | - | - | - | - | - |
1140
+ | error | information | information | information | - |
1141
+
1142
+ <a name='Ruby::TypeArgumentMismatchError'></a>
1143
+ ## Ruby::TypeArgumentMismatchError
1144
+
1145
+ The type application doesn't satisfy generic constraints.
1146
+
1147
+ ### RBS
1148
+
1149
+ ```rbs
1150
+ class Foo
1151
+ def foo: [T < Numeric] (T) -> T
1152
+ end
1153
+ ```
1154
+
1155
+ ### Ruby code
1156
+
1157
+ ```ruby
1158
+ Foo.new.foo("") #$ String
1159
+ ```
1160
+
1161
+ ### Diagnostic
1162
+
1163
+ ```
1164
+ test.rb:7:19: [error] Cannot pass a type `::String` as a type parameter `T < ::Numeric`
1165
+ │ ::String <: ::Numeric
1166
+ │ ::Object <: ::Numeric
1167
+ │ ::BasicObject <: ::Numeric
1168
+
1169
+ │ Diagnostic ID: Ruby::TypeArgumentMismatchError
1170
+
1171
+ └ Foo.new.foo("") #$ String
1172
+ ~~~~~~
1173
+ ```
1174
+
1175
+
1176
+ ### Severity
1177
+
1178
+ | all_error | strict | default | lenient | silent |
1179
+ | - | - | - | - | - |
1180
+ | error | error | hint | - | - |
1181
+
1182
+ <a name='Ruby::UnannotatedEmptyCollection'></a>
1183
+ ## Ruby::UnannotatedEmptyCollection
1184
+
1185
+ An empty array/hash has no type assertion.
1186
+
1187
+ They are typed as `Array[untyped]` or `Hash[untyped, untyped]`,
1188
+ which allows any element to be added.
1189
+
1190
+ ```rb
1191
+ a = []
1192
+ b = {}
1193
+
1194
+ a << 1
1195
+ a << ""
1196
+ ```
1197
+
1198
+ Add type annotation to make your assumption explicit.
1199
+
1200
+ ```rb
1201
+ a = [] #: Array[Integer]
1202
+ b = {} #: untyped
1203
+
1204
+ a << 1
1205
+ a << "" # => Type error
1206
+ ```
1207
+
1208
+ ### Ruby code
1209
+
1210
+ ```ruby
1211
+ a = []
1212
+ b = {}
1213
+ ```
1214
+
1215
+ ### Diagnostic
1216
+
1217
+ ```
1218
+ test.rb:1:4: [error] Empty array doesn't have type annotation
1219
+ │ Diagnostic ID: Ruby::UnannotatedEmptyCollection
1220
+
1221
+ └ a = []
1222
+ ~~
1223
+
1224
+ test.rb:2:4: [error] Empty hash doesn't have type annotation
1225
+ │ Diagnostic ID: Ruby::UnannotatedEmptyCollection
1226
+
1227
+ └ b = {}
1228
+ ~~
1229
+ ```
1230
+
1231
+
1232
+ ### Severity
1233
+
1234
+ | all_error | strict | default | lenient | silent |
1235
+ | - | - | - | - | - |
1236
+ | error | error | warning | hint | - |
1237
+
1238
+ <a name='Ruby::UnexpectedBlockGiven'></a>
1239
+ ## Ruby::UnexpectedBlockGiven
1240
+
1241
+ A method that doesn't accept block is called with a block.
1242
+
1243
+ ### RBS
1244
+
1245
+ ```rbs
1246
+ class Foo
1247
+ def foo: () -> void
1248
+ end
1249
+ ```
1250
+
1251
+ ### Ruby code
1252
+
1253
+ ```ruby
1254
+ Foo.new.foo { 123 }
1255
+ ```
1256
+
1257
+ ### Diagnostic
1258
+
1259
+ ```
1260
+ test.rb:1:12: [warning] The method cannot be called with a block
1261
+ │ Diagnostic ID: Ruby::UnexpectedBlockGiven
1262
+
1263
+ └ Foo.new.foo { 123 }
1264
+ ~~~~~~~
1265
+ ```
1266
+
1267
+
1268
+ ### Severity
1269
+
1270
+ | all_error | strict | default | lenient | silent |
1271
+ | - | - | - | - | - |
1272
+ | error | error | warning | hint | - |
1273
+
1274
+ <a name='Ruby::UnexpectedDynamicMethod'></a>
1275
+ ## Ruby::UnexpectedDynamicMethod
1276
+
1277
+ A `@dynamic` annotation has unknown method name.
1278
+
1279
+ Note that this diagnostic emits only if the class definition in RBS has method definitions.
1280
+
1281
+ ### RBS
1282
+
1283
+ ```rbs
1284
+ class Foo
1285
+ def foo: () -> void
1286
+ end
1287
+ ```
1288
+
1289
+ ### Ruby code
1290
+
1291
+ ```ruby
1292
+ class Foo
1293
+ # @dynamic foo, bar
1294
+ end
1295
+ ```
1296
+
1297
+ ### Diagnostic
1298
+
1299
+ ```
1300
+ test.rb:1:6: [error] @dynamic annotation contains unknown method name `bar`
1301
+ │ Diagnostic ID: Ruby::UnexpectedDynamicMethod
1302
+
1303
+ └ class Foo
1304
+ ~~~
1305
+ ```
1306
+
1307
+
1308
+ ### Severity
1309
+
1310
+ | all_error | strict | default | lenient | silent |
1311
+ | - | - | - | - | - |
1312
+ | error | information | hint | - | - |
1313
+
1314
+ <a name='Ruby::UnexpectedError'></a>
1315
+ ## Ruby::UnexpectedError
1316
+
1317
+ Unexpected error is raised during type checking. Maybe a bug.
1318
+
1319
+
1320
+ ### Severity
1321
+
1322
+ | all_error | strict | default | lenient | silent |
1323
+ | - | - | - | - | - |
1324
+ | error | information | hint | hint | - |
1325
+
1326
+ <a name='Ruby::UnexpectedJump'></a>
1327
+ ## Ruby::UnexpectedJump
1328
+
1329
+ Detected a `break` or `next` statement in invalid context.
1330
+
1331
+ ### Ruby code
1332
+
1333
+ ```ruby
1334
+ break
1335
+ ```
1336
+
1337
+ ### Diagnostic
1338
+
1339
+ ```
1340
+ test.rb:1:0: [error] Cannot jump from here
1341
+ │ Diagnostic ID: Ruby::UnexpectedJump
1342
+
1343
+ └ break
1344
+ ~~~~~
1345
+ ```
1346
+
1347
+
1348
+ ### Severity
1349
+
1350
+ | all_error | strict | default | lenient | silent |
1351
+ | - | - | - | - | - |
1352
+ | error | error | hint | - | - |
1353
+
1354
+ <a name='Ruby::UnexpectedJumpValue'></a>
1355
+ ## Ruby::UnexpectedJumpValue
1356
+
1357
+ A `break` or `next` statement has a value, but the value will be ignored.
1358
+
1359
+ ### Ruby code
1360
+
1361
+ ```ruby
1362
+ while true
1363
+ next 3
1364
+ end
1365
+ ```
1366
+
1367
+ ### Diagnostic
1368
+
1369
+ ```
1370
+ test.rb:2:2: [error] The value given to next will be ignored
1371
+ │ Diagnostic ID: Ruby::UnexpectedJumpValue
1372
+
1373
+ └ next 3
1374
+ ~~~~~~
1375
+ ```
1376
+
1377
+
1378
+ ### Severity
1379
+
1380
+ | all_error | strict | default | lenient | silent |
1381
+ | - | - | - | - | - |
1382
+ | error | error | hint | - | - |
1383
+
1384
+ <a name='Ruby::UnexpectedKeywordArgument'></a>
1385
+ ## Ruby::UnexpectedKeywordArgument
1386
+
1387
+ A method call has an extra keyword argument.
1388
+
1389
+ ### RBS
1390
+
1391
+ ```rbs
1392
+ class Foo
1393
+ def foo: (x: untyped) -> void
1394
+ end
1395
+ ```
1396
+
1397
+ ### Ruby code
1398
+
1399
+ ```ruby
1400
+ Foo.new.foo(x: 1, y: 2)
1401
+ ```
1402
+
1403
+ ### Diagnostic
1404
+
1405
+ ```
1406
+ test.rb:7:18: [error] Unexpected keyword argument
1407
+ │ Diagnostic ID: Ruby::UnexpectedKeywordArgument
1408
+
1409
+ └ Foo.new.foo(x: 1, y: 2)
1410
+ ~
1411
+ ```
1412
+
1413
+
1414
+ ### Severity
1415
+
1416
+ | all_error | strict | default | lenient | silent |
1417
+ | - | - | - | - | - |
1418
+ | error | error | error | information | - |
1419
+
1420
+ <a name='Ruby::UnexpectedPositionalArgument'></a>
1421
+ ## Ruby::UnexpectedPositionalArgument
1422
+
1423
+ A method call has an extra positional argument.
1424
+
1425
+ ### RBS
1426
+
1427
+ ```rbs
1428
+ class Foo
1429
+ def foo: (untyped) -> void
1430
+ end
1431
+ ```
1432
+
1433
+ ### Ruby code
1434
+
1435
+ ```ruby
1436
+ Foo.new.foo(1, 2)
1437
+ ```
1438
+
1439
+ ### Diagnostic
1440
+
1441
+ ```
1442
+ test.rb:7:15: [error] Unexpected positional argument
1443
+ │ Diagnostic ID: Ruby::UnexpectedPositionalArgument
1444
+
1445
+ └ Foo.new.foo(1, 2)
1446
+ ~
1447
+ ```
1448
+
1449
+
1450
+ ### Severity
1451
+
1452
+ | all_error | strict | default | lenient | silent |
1453
+ | - | - | - | - | - |
1454
+ | error | error | error | information | - |
1455
+
1456
+ <a name='Ruby::UnexpectedSuper'></a>
1457
+ ## Ruby::UnexpectedSuper
1458
+
1459
+ A method definition has `super` syntax while no super method is defined in RBS.
1460
+
1461
+ ### RBS
1462
+
1463
+ ```rbs
1464
+ class Foo
1465
+ def foo: () -> void
1466
+ end
1467
+ ```
1468
+
1469
+ ### Ruby code
1470
+
1471
+ ```ruby
1472
+ class Foo
1473
+ def foo = super
1474
+ end
1475
+ ```
1476
+
1477
+ ### Diagnostic
1478
+
1479
+ ```
1480
+ test.rb:2:12: [information] No superclass method `foo` defined
1481
+ │ Diagnostic ID: Ruby::UnexpectedSuper
1482
+
1483
+ └ def foo = super
1484
+ ~~~~~
1485
+ ```
1486
+
1487
+
1488
+ ### Severity
1489
+
1490
+ | all_error | strict | default | lenient | silent |
1491
+ | - | - | - | - | - |
1492
+ | error | error | information | - | - |
1493
+
1494
+ <a name='Ruby::UnexpectedTypeArgument'></a>
1495
+ ## Ruby::UnexpectedTypeArgument
1496
+
1497
+ An extra type application is given to a method call.
1498
+
1499
+ ### RBS
1500
+
1501
+ ```rbs
1502
+ class Foo
1503
+ def foo: [T] (T) -> T
1504
+ end
1505
+ ```
1506
+
1507
+ ### Ruby code
1508
+
1509
+ ```ruby
1510
+ Foo.new.foo(1) #$ Integer, Integer
1511
+ ```
1512
+
1513
+ ### Diagnostic
1514
+
1515
+ ```
1516
+ test.rb:8:27: [error] Unexpected type arg is given to method type `[T] (T) -> T`
1517
+ │ Diagnostic ID: Ruby::UnexpectedTypeArgument
1518
+
1519
+ └ Foo.new.foo(1) #$ Integer, Integer
1520
+ ~~~~~~~
1521
+ ```
1522
+
1523
+
1524
+ ### Severity
1525
+
1526
+ | all_error | strict | default | lenient | silent |
1527
+ | - | - | - | - | - |
1528
+ | error | error | hint | - | - |
1529
+
1530
+ <a name='Ruby::UnexpectedYield'></a>
1531
+ ## Ruby::UnexpectedYield
1532
+
1533
+ A method definition without block has `yield` syntax.
1534
+
1535
+ ### RBS
1536
+
1537
+ ```rbs
1538
+ class Foo
1539
+ def foo: () -> void
1540
+ end
1541
+ ```
1542
+
1543
+ ### Ruby code
1544
+
1545
+ ```ruby
1546
+ class Foo
1547
+ def foo
1548
+ yield
1549
+ end
1550
+ end
1551
+ ```
1552
+
1553
+ ### Diagnostic
1554
+
1555
+ ```
1556
+ test.rb:3:4: [hint] Cannot detect the type of the expression
1557
+ │ Diagnostic ID: Ruby::FallbackAny
1558
+
1559
+ └ yield
1560
+ ~~~~~
1561
+ ```
1562
+
1563
+
1564
+ ### Severity
1565
+
1566
+ | all_error | strict | default | lenient | silent |
1567
+ | - | - | - | - | - |
1568
+ | error | error | warning | information | - |
1569
+
1570
+ <a name='Ruby::UnknownConstant'></a>
1571
+ ## Ruby::UnknownConstant
1572
+
1573
+ A constant is not defined in the RBS definition.
1574
+
1575
+ ### Ruby code
1576
+
1577
+ ```ruby
1578
+ FOO
1579
+ ```
1580
+
1581
+ ### Diagnostic
1582
+
1583
+ ```
1584
+ test.rb:1:0: [error] Cannot find the declaration of constant: `FOO`
1585
+ │ Diagnostic ID: Ruby::UnknownConstant
1586
+
1587
+ └ FOO
1588
+ ~~~
1589
+ ```
1590
+
1591
+
1592
+ ### Severity
1593
+
1594
+ | all_error | strict | default | lenient | silent |
1595
+ | - | - | - | - | - |
1596
+ | error | error | warning | hint | - |
1597
+
1598
+ <a name='Ruby::UnknownGlobalVariable'></a>
1599
+ ## Ruby::UnknownGlobalVariable
1600
+
1601
+ Short explanation ending with `.`
1602
+
1603
+ ### Ruby code
1604
+
1605
+ ```ruby
1606
+ $foo
1607
+ ```
1608
+
1609
+ ### Diagnostic
1610
+
1611
+ ```
1612
+ test.rb:1:0: [error] Cannot find the declaration of global variable: `$foo`
1613
+ │ Diagnostic ID: Ruby::UnknownGlobalVariable
1614
+
1615
+ └ $foo
1616
+ ~~~~
1617
+ ```
1618
+
1619
+
1620
+ ### Severity
1621
+
1622
+ | all_error | strict | default | lenient | silent |
1623
+ | - | - | - | - | - |
1624
+ | error | error | warning | hint | - |
1625
+
1626
+ <a name='Ruby::UnknownInstanceVariable'></a>
1627
+ ## Ruby::UnknownInstanceVariable
1628
+
1629
+ An instance variable is not defined in RBS definition.
1630
+
1631
+ ### Ruby code
1632
+
1633
+ ```ruby
1634
+ class Foo
1635
+ def foo
1636
+ @foo = 'foo'
1637
+ end
1638
+ end
1639
+ ```
1640
+
1641
+ ### Diagnostic
1642
+
1643
+ ```
1644
+ test.rb:3:4: [error] Cannot find the declaration of instance variable: `@foo`
1645
+ │ Diagnostic ID: Ruby::UnknownInstanceVariable
1646
+
1647
+ └ @foo = 'foo'
1648
+ ~~~~
1649
+ ```
1650
+
1651
+
1652
+ ### Severity
1653
+
1654
+ | all_error | strict | default | lenient | silent |
1655
+ | - | - | - | - | - |
1656
+ | error | error | information | hint | - |
1657
+
1658
+ <a name='Ruby::UnknownRecordKey'></a>
1659
+ ## Ruby::UnknownRecordKey
1660
+
1661
+ An unknown key is given to record type.
1662
+
1663
+ ### Ruby code
1664
+
1665
+ ```ruby
1666
+ { name: "soutaro", email: "soutaro@example.com" } #: { name: String }
1667
+ ```
1668
+
1669
+ ### Diagnostic
1670
+
1671
+ ```
1672
+ test.rb:1:19: [error] Unknown key `:email` is given to a record type
1673
+ │ Diagnostic ID: Ruby::UnknownRecordKey
1674
+
1675
+ └ { name: "soutaro", email: "soutaro@example.com" } #: { name: String }
1676
+ ~~~~~
1677
+ ```
1678
+
1679
+
1680
+ ### Severity
1681
+
1682
+ | all_error | strict | default | lenient | silent |
1683
+ | - | - | - | - | - |
1684
+ | error | warning | information | hint | - |
1685
+
1686
+ <a name='Ruby::UnreachableBranch'></a>
1687
+ ## Ruby::UnreachableBranch
1688
+
1689
+ A conditional always/never hold.
1690
+
1691
+ ### Ruby code
1692
+
1693
+ ```ruby
1694
+ if false
1695
+ 1
1696
+ end
1697
+ ```
1698
+
1699
+ ### Diagnostic
1700
+
1701
+ ```
1702
+ test.rb:1:0: [error] The branch is unreachable
1703
+ │ Diagnostic ID: Ruby::UnreachableBranch
1704
+
1705
+ └ if false
1706
+ ~~
1707
+ ```
1708
+
1709
+
1710
+ ### Severity
1711
+
1712
+ | all_error | strict | default | lenient | silent |
1713
+ | - | - | - | - | - |
1714
+ | error | information | hint | hint | - |
1715
+
1716
+ <a name='Ruby::UnreachableValueBranch'></a>
1717
+ ## Ruby::UnreachableValueBranch
1718
+
1719
+ A branch has a type other than `bot`, but unreachable.
1720
+
1721
+ This diagnostic skips the `bot` branch because we often have `else` branch to make the code defensive.
1722
+
1723
+ ### Ruby code
1724
+
1725
+ ```ruby
1726
+ x = 1
1727
+
1728
+ case x
1729
+ when Integer
1730
+ "one"
1731
+ when String
1732
+ "two"
1733
+ when Symbol
1734
+ raise "Unexpected value"
1735
+ end
1736
+ ```
1737
+
1738
+ ### Diagnostic
1739
+
1740
+ ```
1741
+ test.rb:5:0: [error] The branch may evaluate to a value of `::String` but unreachable
1742
+ │ Diagnostic ID: Ruby::UnreachableValueBranch
1743
+
1744
+ └ when String
1745
+ ~~~~
1746
+ ```
1747
+
1748
+
1749
+ ### Severity
1750
+
1751
+ | all_error | strict | default | lenient | silent |
1752
+ | - | - | - | - | - |
1753
+ | error | warning | hint | hint | - |
1754
+
1755
+ <a name='Ruby::UnresolvedOverloading'></a>
1756
+ ## Ruby::UnresolvedOverloading
1757
+
1758
+ A method call has type errors, no more specific explanation cannot be reported.
1759
+
1760
+ ### Ruby code
1761
+
1762
+ ```ruby
1763
+ 3 + "foo"
1764
+ ```
1765
+
1766
+ ### Diagnostic
1767
+
1768
+ ```
1769
+ test.rb:1:0: [error] Cannot find compatible overloading of method `+` of type `::Integer`
1770
+ │ Method types:
1771
+ │ def +: (::Integer) -> ::Integer
1772
+ │ | (::Float) -> ::Float
1773
+ │ | (::Rational) -> ::Rational
1774
+ │ | (::Complex) -> ::Complex
1775
+
1776
+ │ Diagnostic ID: Ruby::UnresolvedOverloading
1777
+
1778
+ └ 3 + "foo"
1779
+ ~~~~~~~~~
1780
+ ```
1781
+
1782
+
1783
+ ### Severity
1784
+
1785
+ | all_error | strict | default | lenient | silent |
1786
+ | - | - | - | - | - |
1787
+ | error | error | error | information | - |
1788
+
1789
+ <a name='Ruby::UnsatisfiableConstraint'></a>
1790
+ ## Ruby::UnsatisfiableConstraint
1791
+
1792
+ Failed to solve constraint collected from a method call typing.
1793
+
1794
+
1795
+ ### Severity
1796
+
1797
+ | all_error | strict | default | lenient | silent |
1798
+ | - | - | - | - | - |
1799
+ | error | error | hint | hint | - |
1800
+
1801
+ <a name='Ruby::UnsupportedSyntax'></a>
1802
+ ## Ruby::UnsupportedSyntax
1803
+
1804
+ The syntax is not currently supported by Steep.
1805
+
1806
+
1807
+ ### Severity
1808
+
1809
+ | all_error | strict | default | lenient | silent |
1810
+ | - | - | - | - | - |
1811
+ | error | information | hint | hint | - |
1812
+