steep 0.39.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/Rakefile +5 -2
  5. data/bin/output_rebaseline.rb +49 -0
  6. data/bin/output_test.rb +93 -0
  7. data/lib/steep.rb +8 -3
  8. data/lib/steep/cli.rb +1 -1
  9. data/lib/steep/diagnostic/helper.rb +17 -0
  10. data/lib/steep/diagnostic/lsp_formatter.rb +16 -0
  11. data/lib/steep/diagnostic/ruby.rb +623 -0
  12. data/lib/steep/diagnostic/signature.rb +224 -0
  13. data/lib/steep/drivers/annotations.rb +13 -6
  14. data/lib/steep/drivers/check.rb +83 -60
  15. data/lib/steep/drivers/diagnostic_printer.rb +94 -0
  16. data/lib/steep/drivers/stats.rb +125 -29
  17. data/lib/steep/drivers/trace_printer.rb +5 -1
  18. data/lib/steep/drivers/validate.rb +13 -6
  19. data/lib/steep/drivers/watch.rb +26 -9
  20. data/lib/steep/drivers/worker.rb +5 -0
  21. data/lib/steep/project/options.rb +4 -4
  22. data/lib/steep/project/signature_file.rb +8 -2
  23. data/lib/steep/project/stats_calculator.rb +80 -0
  24. data/lib/steep/project/target.rb +64 -53
  25. data/lib/steep/range_extension.rb +29 -0
  26. data/lib/steep/server/base_worker.rb +42 -4
  27. data/lib/steep/server/code_worker.rb +37 -24
  28. data/lib/steep/server/interaction_worker.rb +1 -0
  29. data/lib/steep/server/master.rb +268 -82
  30. data/lib/steep/server/signature_worker.rb +7 -59
  31. data/lib/steep/server/worker_process.rb +9 -9
  32. data/lib/steep/signature/validator.rb +33 -9
  33. data/lib/steep/type_construction.rb +276 -194
  34. data/lib/steep/version.rb +1 -1
  35. data/smoke/alias/a.rb +0 -3
  36. data/smoke/alias/b.rb +0 -1
  37. data/smoke/alias/c.rb +0 -2
  38. data/smoke/alias/test.yaml +73 -0
  39. data/smoke/and/a.rb +0 -3
  40. data/smoke/and/test.yaml +24 -0
  41. data/smoke/array/a.rb +0 -3
  42. data/smoke/array/b.rb +0 -2
  43. data/smoke/array/c.rb +0 -1
  44. data/smoke/array/test.yaml +80 -0
  45. data/smoke/block/a.rb +0 -2
  46. data/smoke/block/b.rb +0 -2
  47. data/smoke/block/d.rb +0 -4
  48. data/smoke/block/test.yaml +96 -0
  49. data/smoke/broken/Steepfile +5 -0
  50. data/smoke/broken/broken.rb +0 -0
  51. data/smoke/broken/broken.rbs +0 -0
  52. data/smoke/broken/test.yaml +6 -0
  53. data/smoke/case/a.rb +0 -3
  54. data/smoke/case/test.yaml +36 -0
  55. data/smoke/class/a.rb +0 -3
  56. data/smoke/class/c.rb +0 -1
  57. data/smoke/class/f.rb +0 -1
  58. data/smoke/class/g.rb +0 -2
  59. data/smoke/class/i.rb +0 -2
  60. data/smoke/class/test.yaml +89 -0
  61. data/smoke/const/a.rb +0 -3
  62. data/smoke/const/b.rb +7 -0
  63. data/smoke/const/b.rbs +5 -0
  64. data/smoke/const/test.yaml +96 -0
  65. data/smoke/diagnostics-rbs-duplicated/Steepfile +5 -0
  66. data/smoke/diagnostics-rbs-duplicated/a.rbs +5 -0
  67. data/smoke/diagnostics-rbs-duplicated/test.yaml +10 -0
  68. data/smoke/diagnostics-rbs/Steepfile +5 -0
  69. data/smoke/diagnostics-rbs/duplicated-method-definition.rbs +20 -0
  70. data/smoke/diagnostics-rbs/generic-parameter-mismatch.rbs +7 -0
  71. data/smoke/diagnostics-rbs/invalid-method-overload.rbs +3 -0
  72. data/smoke/diagnostics-rbs/invalid-type-application.rbs +7 -0
  73. data/smoke/diagnostics-rbs/invalid_variance_annotation.rbs +3 -0
  74. data/smoke/diagnostics-rbs/recursive-alias.rbs +5 -0
  75. data/smoke/diagnostics-rbs/recursive-class.rbs +8 -0
  76. data/smoke/diagnostics-rbs/superclass-mismatch.rbs +7 -0
  77. data/smoke/diagnostics-rbs/test.yaml +142 -0
  78. data/smoke/diagnostics-rbs/unknown-method-alias.rbs +3 -0
  79. data/smoke/diagnostics-rbs/unknown-type-name.rbs +13 -0
  80. data/smoke/diagnostics/Steepfile +5 -0
  81. data/smoke/diagnostics/a.rbs +26 -0
  82. data/smoke/diagnostics/argument_type_mismatch.rb +1 -0
  83. data/smoke/diagnostics/block_body_type_mismatch.rb +1 -0
  84. data/smoke/diagnostics/block_type_mismatch.rb +3 -0
  85. data/smoke/diagnostics/break_type_mismatch.rb +1 -0
  86. data/smoke/diagnostics/else_on_exhaustive_case.rb +12 -0
  87. data/smoke/diagnostics/incompatible_annotation.rb +6 -0
  88. data/smoke/diagnostics/incompatible_argument.rb +1 -0
  89. data/smoke/diagnostics/incompatible_assignment.rb +8 -0
  90. data/smoke/diagnostics/method_arity_mismatch.rb +11 -0
  91. data/smoke/diagnostics/method_body_type_mismatch.rb +6 -0
  92. data/smoke/diagnostics/method_definition_missing.rb +2 -0
  93. data/smoke/diagnostics/method_return_type_annotation_mismatch.rb +7 -0
  94. data/smoke/diagnostics/missing_keyword.rb +1 -0
  95. data/smoke/diagnostics/no_method.rb +1 -0
  96. data/smoke/diagnostics/required_block_missing.rb +1 -0
  97. data/smoke/diagnostics/return_type_mismatch.rb +6 -0
  98. data/smoke/diagnostics/test.yaml +333 -0
  99. data/smoke/diagnostics/unexpected_block_given.rb +1 -0
  100. data/smoke/diagnostics/unexpected_dynamic_method.rb +3 -0
  101. data/smoke/diagnostics/unexpected_jump.rb +4 -0
  102. data/smoke/diagnostics/unexpected_jump_value.rb +3 -0
  103. data/smoke/diagnostics/unexpected_keyword.rb +1 -0
  104. data/smoke/diagnostics/unexpected_splat.rb +1 -0
  105. data/smoke/diagnostics/unexpected_yield.rb +6 -0
  106. data/smoke/diagnostics/unknown_constant_assigned.rb +7 -0
  107. data/smoke/diagnostics/unresolved_overloading.rb +1 -0
  108. data/smoke/diagnostics/unsatisfiable_constraint.rb +7 -0
  109. data/smoke/diagnostics/unsupported_syntax.rb +2 -0
  110. data/smoke/dstr/a.rb +0 -1
  111. data/smoke/dstr/test.yaml +10 -0
  112. data/smoke/ensure/a.rb +0 -4
  113. data/smoke/ensure/test.yaml +47 -0
  114. data/smoke/enumerator/a.rb +0 -6
  115. data/smoke/enumerator/b.rb +0 -3
  116. data/smoke/enumerator/test.yaml +100 -0
  117. data/smoke/extension/a.rb +0 -1
  118. data/smoke/extension/b.rb +0 -2
  119. data/smoke/extension/c.rb +0 -1
  120. data/smoke/extension/test.yaml +50 -0
  121. data/smoke/hash/b.rb +0 -1
  122. data/smoke/hash/c.rb +0 -3
  123. data/smoke/hash/d.rb +0 -1
  124. data/smoke/hash/e.rb +0 -1
  125. data/smoke/hash/test.yaml +62 -0
  126. data/smoke/hello/hello.rb +0 -2
  127. data/smoke/hello/test.yaml +18 -0
  128. data/smoke/if/a.rb +0 -2
  129. data/smoke/if/test.yaml +27 -0
  130. data/smoke/implements/a.rb +0 -2
  131. data/smoke/implements/test.yaml +16 -0
  132. data/smoke/initialize/test.yaml +4 -0
  133. data/smoke/integer/a.rb +0 -7
  134. data/smoke/integer/test.yaml +66 -0
  135. data/smoke/interface/a.rb +0 -2
  136. data/smoke/interface/test.yaml +16 -0
  137. data/smoke/kwbegin/a.rb +0 -1
  138. data/smoke/kwbegin/test.yaml +14 -0
  139. data/smoke/lambda/a.rb +1 -4
  140. data/smoke/lambda/test.yaml +28 -0
  141. data/smoke/literal/a.rb +0 -5
  142. data/smoke/literal/b.rb +0 -2
  143. data/smoke/literal/test.yaml +79 -0
  144. data/smoke/map/test.yaml +4 -0
  145. data/smoke/method/a.rb +0 -5
  146. data/smoke/method/b.rb +0 -1
  147. data/smoke/method/test.yaml +71 -0
  148. data/smoke/module/a.rb +0 -2
  149. data/smoke/module/b.rb +0 -2
  150. data/smoke/module/c.rb +0 -1
  151. data/smoke/module/d.rb +0 -1
  152. data/smoke/module/f.rb +0 -2
  153. data/smoke/module/test.yaml +51 -0
  154. data/smoke/regexp/a.rb +0 -38
  155. data/smoke/regexp/b.rb +0 -26
  156. data/smoke/regexp/test.yaml +372 -0
  157. data/smoke/regression/set_divide.rb +0 -4
  158. data/smoke/regression/test.yaml +38 -0
  159. data/smoke/rescue/a.rb +0 -5
  160. data/smoke/rescue/test.yaml +60 -0
  161. data/smoke/self/a.rb +0 -2
  162. data/smoke/self/test.yaml +16 -0
  163. data/smoke/skip/skip.rb +0 -2
  164. data/smoke/skip/test.yaml +16 -0
  165. data/smoke/stdout/test.yaml +4 -0
  166. data/smoke/super/a.rb +0 -4
  167. data/smoke/super/test.yaml +52 -0
  168. data/smoke/toplevel/a.rb +0 -1
  169. data/smoke/toplevel/test.yaml +12 -0
  170. data/smoke/tsort/a.rb +0 -3
  171. data/smoke/tsort/test.yaml +32 -0
  172. data/smoke/type_case/a.rb +0 -4
  173. data/smoke/type_case/test.yaml +33 -0
  174. data/smoke/yield/a.rb +0 -3
  175. data/smoke/yield/b.rb +6 -0
  176. data/smoke/yield/test.yaml +49 -0
  177. data/steep.gemspec +3 -3
  178. metadata +108 -17
  179. data/bin/smoke_runner.rb +0 -139
  180. data/lib/steep/drivers/signature_error_printer.rb +0 -25
  181. data/lib/steep/errors.rb +0 -594
  182. data/lib/steep/signature/errors.rb +0 -128
  183. data/lib/steep/type_assignability.rb +0 -367
@@ -1,25 +0,0 @@
1
- module Steep
2
- module Drivers
3
- class SignatureErrorPrinter
4
- attr_reader :stdout
5
- attr_reader :stderr
6
-
7
- def initialize(stdout:, stderr:)
8
- @stdout = stdout
9
- @stderr = stderr
10
- end
11
-
12
- def print_syntax_errors(errors)
13
- errors.each do |error|
14
- stderr.puts error.message
15
- end
16
- end
17
-
18
- def print_semantic_errors(errors)
19
- errors.each do |error|
20
- error.puts stderr
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,594 +0,0 @@
1
- module Steep
2
- module Errors
3
- class Base
4
- attr_reader :node
5
-
6
- def initialize(node:)
7
- @node = node
8
- end
9
-
10
- def location_to_str
11
- file = Rainbow(node.loc.expression.source_buffer.name).cyan
12
- line = Rainbow(node.loc.first_line).bright
13
- column = Rainbow(node.loc.column).bright
14
- "#{file}:#{line}:#{column}"
15
- end
16
-
17
- def format_message(message, class_name: self.class.name.split("::").last)
18
- if message.empty?
19
- "#{location_to_str}: #{Rainbow(class_name).red}"
20
- else
21
- "#{location_to_str}: #{Rainbow(class_name).red}: #{message}"
22
- end
23
- end
24
-
25
- def print_to(io)
26
- source = node.loc.expression.source
27
- io.puts "#{to_s} (#{Rainbow(source.split(/\n/).first).blue})"
28
- end
29
- end
30
-
31
- module ResultPrinter
32
- def print_result_to(io, level: 2)
33
- printer = Drivers::TracePrinter.new(io)
34
- printer.print result.trace, level: level
35
- io.puts "==> #{result.error.message}"
36
- end
37
-
38
- def print_to(io)
39
- super
40
- print_result_to io
41
- end
42
- end
43
-
44
- class IncompatibleAssignment < Base
45
- attr_reader :lhs_type
46
- attr_reader :rhs_type
47
- attr_reader :result
48
-
49
- include ResultPrinter
50
-
51
- def initialize(node:, lhs_type:, rhs_type:, result:)
52
- super(node: node)
53
- @lhs_type = lhs_type
54
- @rhs_type = rhs_type
55
- @result = result
56
- end
57
-
58
- def to_s
59
- format_message "lhs_type=#{lhs_type}, rhs_type=#{rhs_type}"
60
- end
61
- end
62
-
63
- class IncompatibleArguments < Base
64
- attr_reader :node
65
- attr_reader :receiver_type
66
- attr_reader :method_type
67
-
68
- def initialize(node:, receiver_type:, method_type:)
69
- super(node: node)
70
- @receiver_type = receiver_type
71
- @method_type = method_type
72
- end
73
-
74
- def to_s
75
- format_message "receiver=#{receiver_type}, method_type=#{method_type}"
76
- end
77
- end
78
-
79
- class UnresolvedOverloading < Base
80
- attr_reader :node
81
- attr_reader :receiver_type
82
- attr_reader :method_name
83
- attr_reader :method_types
84
-
85
- def initialize(node:, receiver_type:, method_name:, method_types:)
86
- super node: node
87
- @receiver_type = receiver_type
88
- @method_name = method_name
89
- @method_types = method_types
90
- end
91
-
92
- def to_s
93
- format_message "receiver=#{receiver_type}, method_name=#{method_name}, method_types=#{method_types.join(" | ")}"
94
- end
95
- end
96
-
97
- class ArgumentTypeMismatch < Base
98
- attr_reader :node
99
- attr_reader :expected
100
- attr_reader :actual
101
- attr_reader :receiver_type
102
-
103
- def initialize(node:, receiver_type:, expected:, actual:)
104
- super(node: node)
105
- @receiver_type = receiver_type
106
- @expected = expected
107
- @actual = actual
108
- end
109
-
110
- def to_s
111
- format_message "receiver=#{receiver_type}, expected=#{expected}, actual=#{actual}"
112
- end
113
- end
114
-
115
- class BlockParameterTypeMismatch < Base
116
- attr_reader :expected
117
- attr_reader :actual
118
-
119
- def initialize(node:, expected:, actual:)
120
- super(node: node)
121
- @expected = expected
122
- @actual = actual
123
- end
124
-
125
- def to_s
126
- format_message "expected=#{expected}, actual=#{actual}"
127
- end
128
- end
129
-
130
- class NoMethod < Base
131
- attr_reader :type
132
- attr_reader :method
133
-
134
- def initialize(node:, type:, method:)
135
- super(node: node)
136
- @type = type
137
- @method = method
138
- end
139
-
140
- def to_s
141
- format_message "type=#{type}, method=#{method}", class_name: "NoMethodError"
142
- end
143
- end
144
-
145
- class ReturnTypeMismatch < Base
146
- attr_reader :expected
147
- attr_reader :actual
148
- attr_reader :result
149
-
150
- include ResultPrinter
151
-
152
- def initialize(node:, expected:, actual:, result:)
153
- super(node: node)
154
- @expected = expected
155
- @actual = actual
156
- @result = result
157
- end
158
-
159
- def to_s
160
- format_message "expected=#{expected}, actual=#{actual}"
161
- end
162
- end
163
-
164
- class UnexpectedBlockGiven < Base
165
- attr_reader :method_type
166
-
167
- def initialize(node:, method_type:)
168
- super(node: node)
169
- @method_type = method_type
170
- end
171
-
172
- def to_s
173
- format_message "method_type=#{method_type}"
174
- end
175
- end
176
-
177
- class RequiredBlockMissing < Base
178
- attr_reader :method_type
179
-
180
- def initialize(node:, method_type:)
181
- super(node: node)
182
- @method_type = method_type
183
- end
184
-
185
- def to_s
186
- format_message "method_type=#{method_type}"
187
- end
188
- end
189
-
190
- class BlockTypeMismatch < Base
191
- attr_reader :expected
192
- attr_reader :actual
193
- attr_reader :result
194
-
195
- include ResultPrinter
196
-
197
- def initialize(node:, expected:, actual:, result:)
198
- super(node: node)
199
- @expected = expected
200
- @actual = actual
201
- @result = result
202
- end
203
-
204
- def to_s
205
- format_message "expected=#{expected}, actual=#{actual}"
206
- end
207
- end
208
-
209
- class BlockBodyTypeMismatch < Base
210
- attr_reader :expected
211
- attr_reader :actual
212
- attr_reader :result
213
-
214
- include ResultPrinter
215
-
216
- def initialize(node:, expected:, actual:, result:)
217
- super(node: node)
218
- @expected = expected
219
- @actual = actual
220
- @result = result
221
- end
222
-
223
- def to_s
224
- format_message "expected=#{expected}, actual=#{actual}"
225
- end
226
- end
227
-
228
- class BreakTypeMismatch < Base
229
- attr_reader :expected
230
- attr_reader :actual
231
- attr_reader :result
232
-
233
- include ResultPrinter
234
-
235
- def initialize(node:, expected:, actual:, result:)
236
- super(node: node)
237
- @expected = expected
238
- @actual = actual
239
- @result = result
240
- end
241
-
242
- def to_s
243
- format_message "expected=#{expected}, actual=#{actual}"
244
- end
245
- end
246
-
247
- class UnexpectedJump < Base
248
- def to_s
249
- format_message ""
250
- end
251
- end
252
-
253
- class UnexpectedJumpValue < Base
254
- def to_s
255
- format_message ""
256
- end
257
- end
258
-
259
- class MethodArityMismatch < Base
260
- def to_s
261
- format_message "method=#{node.children[0]}"
262
- end
263
- end
264
-
265
- class IncompatibleMethodTypeAnnotation < Base
266
- attr_reader :interface_method
267
- attr_reader :annotation_method
268
- attr_reader :result
269
-
270
- include ResultPrinter
271
-
272
- def initialize(node:, interface_method:, annotation_method:, result:)
273
- super(node: node)
274
- @interface_method = interface_method
275
- @annotation_method = annotation_method
276
- @result = result
277
- end
278
-
279
- def to_s
280
- format_message "interface_method=#{interface_method.type_name}.#{interface_method.name}, annotation_method=#{annotation_method.name}"
281
- end
282
- end
283
-
284
- class MethodDefinitionWithOverloading < Base
285
- attr_reader :method
286
-
287
- def initialize(node:, method:)
288
- super(node: node)
289
- @method = method
290
- end
291
-
292
- def to_s
293
- format_message "method=#{method.name}, types=#{method.types.join(" | ")}"
294
- end
295
- end
296
-
297
- class MethodReturnTypeAnnotationMismatch < Base
298
- attr_reader :method_type
299
- attr_reader :annotation_type
300
- attr_reader :result
301
-
302
- include ResultPrinter
303
-
304
- def initialize(node:, method_type:, annotation_type:, result:)
305
- super(node: node)
306
- @method_type = method_type
307
- @annotation_type = annotation_type
308
- @result = result
309
- end
310
-
311
- def to_s
312
- format_message "method_type=#{method_type.return_type}, annotation_type=#{annotation_type}"
313
- end
314
- end
315
-
316
- class MethodBodyTypeMismatch < Base
317
- attr_reader :expected
318
- attr_reader :actual
319
- attr_reader :result
320
-
321
- include ResultPrinter
322
-
323
- def initialize(node:, expected:, actual:, result:)
324
- super(node: node)
325
- @expected = expected
326
- @actual = actual
327
- @result = result
328
- end
329
-
330
- def to_s
331
- method = case node.type
332
- when :def
333
- node.children[0]
334
- when :defs
335
- prefix = node.children[0].type == :self ? "self" : "*"
336
- "#{prefix}.#{node.children[1]}"
337
- end
338
- format_message "method=#{method}, expected=#{expected}, actual=#{actual}"
339
- end
340
- end
341
-
342
- class UnexpectedYield < Base
343
- def to_s
344
- format_message ""
345
- end
346
- end
347
-
348
- class UnexpectedSuper < Base
349
- attr_reader :method
350
-
351
- def initialize(node:, method:)
352
- super(node: node)
353
- @method = method
354
- end
355
-
356
- def to_s
357
- format_message "method=#{method}"
358
- end
359
- end
360
-
361
- class IncompatibleZuper < Base
362
- attr_reader :method
363
-
364
- def initialize(node:, method:)
365
- super(node: node)
366
- @method = method
367
- end
368
-
369
- def to_s
370
- format_message "method=#{method}"
371
- end
372
- end
373
-
374
- class MethodDefinitionMissing < Base
375
- attr_reader :module_name
376
- attr_reader :kind
377
- attr_reader :missing_method
378
-
379
- def initialize(node:, module_name:, kind:, missing_method:)
380
- super(node: node)
381
- @module_name = module_name
382
- @kind = kind
383
- @missing_method = missing_method
384
- end
385
-
386
- def to_s
387
- method = case kind
388
- when :instance
389
- "#{missing_method}"
390
- when :module
391
- "self.#{missing_method}"
392
- end
393
- format_message "module=#{module_name}, method=#{method}"
394
- end
395
- end
396
-
397
- class UnexpectedDynamicMethod < Base
398
- attr_reader :module_name
399
- attr_reader :method_name
400
-
401
- def initialize(node:, module_name:, method_name:)
402
- @node = node
403
- @module_name = module_name
404
- @method_name = method_name
405
- end
406
-
407
- def to_s
408
- format_message "module=#{module_name}, method=#{method_name}"
409
- end
410
- end
411
-
412
- class UnknownConstantAssigned < Base
413
- attr_reader :type
414
-
415
- def initialize(node:, type:)
416
- super(node: node)
417
- @type = type
418
- end
419
-
420
- def to_s
421
- format_message "type=#{type}"
422
- end
423
- end
424
-
425
- class FallbackAny < Base
426
- def initialize(node:)
427
- @node = node
428
- end
429
-
430
- def to_s
431
- format_message ""
432
- end
433
- end
434
-
435
- class UnsatisfiableConstraint < Base
436
- attr_reader :method_type
437
- attr_reader :var
438
- attr_reader :sub_type
439
- attr_reader :super_type
440
- attr_reader :result
441
-
442
- def initialize(node:, method_type:, var:, sub_type:, super_type:, result:)
443
- super(node: node)
444
- @method_type = method_type
445
- @var = var
446
- @sub_type = sub_type
447
- @super_type = super_type
448
- @result = result
449
- end
450
-
451
- include ResultPrinter
452
-
453
- def to_s
454
- format_message "method_type=#{method_type}, constraint=#{sub_type} <: '#{var} <: #{super_type}"
455
- end
456
- end
457
-
458
- class IncompatibleAnnotation < Base
459
- attr_reader :var_name
460
- attr_reader :result
461
- attr_reader :relation
462
-
463
- def initialize(node:, var_name:, result:, relation:)
464
- super(node: node)
465
- @var_name = var_name
466
- @result = result
467
- @relation = relation
468
- end
469
-
470
- include ResultPrinter
471
-
472
- def to_s
473
- format_message "var_name=#{var_name}, #{relation}"
474
- end
475
- end
476
-
477
- class IncompatibleTypeCase < Base
478
- attr_reader :var_name
479
- attr_reader :result
480
- attr_reader :relation
481
-
482
- def initialize(node:, var_name:, result:, relation:)
483
- super(node: node)
484
- @var_name = var_name
485
- @result = result
486
- @relation = relation
487
- end
488
-
489
- include ResultPrinter
490
-
491
- def to_s
492
- format_message "var_name=#{var_name}, #{relation}"
493
- end
494
- end
495
-
496
- class ElseOnExhaustiveCase < Base
497
- attr_reader :type
498
-
499
- def initialize(node:, type:)
500
- super(node: node)
501
- @type = type
502
- end
503
-
504
- def to_s
505
- format_message "type=#{type}"
506
- end
507
- end
508
-
509
- class UnexpectedSplat < Base
510
- attr_reader :type
511
-
512
- def initialize(node:, type:)
513
- super(node: node)
514
- @type = type
515
- end
516
-
517
- def to_s
518
- format_message "type=#{type}"
519
- end
520
- end
521
-
522
- class IncompatibleTuple < Base
523
- attr_reader :expected_tuple
524
- include ResultPrinter
525
-
526
- def initialize(node:, expected_tuple:, result:)
527
- super(node: node)
528
- @result = result
529
- @expected_tuple = expected_tuple
530
- end
531
-
532
- def to_s
533
- format_message "expected_tuple=#{expected_tuple}"
534
- end
535
- end
536
-
537
- class UnexpectedKeyword < Base
538
- attr_reader :unexpected_keywords
539
-
540
- def initialize(node:, unexpected_keywords:)
541
- super(node: node)
542
- @unexpected_keywords = unexpected_keywords
543
- end
544
-
545
- def to_s
546
- format_message unexpected_keywords.to_a.join(", ")
547
- end
548
- end
549
-
550
- class MissingKeyword < Base
551
- attr_reader :missing_keywords
552
-
553
- def initialize(node:, missing_keywords:)
554
- super(node: node)
555
- @missing_keywords = missing_keywords
556
- end
557
-
558
- def to_s
559
- format_message missing_keywords.to_a.join(", ")
560
- end
561
- end
562
-
563
- class UnsupportedSyntax < Base
564
- attr_reader :message
565
-
566
- def initialize(node:, message: nil)
567
- super(node: node)
568
- @message = message
569
- end
570
-
571
- def to_s
572
- format_message(message || "#{node.type} is not supported")
573
- end
574
- end
575
-
576
- class UnexpectedError < Base
577
- attr_reader :message
578
- attr_reader :error
579
-
580
- def initialize(node:, error:)
581
- super(node: node)
582
- @error = error
583
- @message = error.message
584
- end
585
-
586
- def to_s
587
- format_message <<-MESSAGE
588
- #{error.class}
589
- >> #{message}
590
- MESSAGE
591
- end
592
- end
593
- end
594
- end