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