steep 0.35.0 → 0.40.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 +31 -0
- data/Rakefile +5 -2
- data/bin/output_rebaseline.rb +49 -0
- data/bin/output_test.rb +93 -0
- data/lib/steep.rb +14 -3
- data/lib/steep/ast/types/bot.rb +1 -1
- data/lib/steep/ast/types/factory.rb +122 -53
- data/lib/steep/ast/types/logic.rb +33 -1
- data/lib/steep/ast/types/proc.rb +32 -20
- data/lib/steep/ast/types/top.rb +1 -1
- data/lib/steep/cli.rb +1 -1
- data/lib/steep/diagnostic/helper.rb +17 -0
- data/lib/steep/diagnostic/lsp_formatter.rb +16 -0
- data/lib/steep/diagnostic/ruby.rb +623 -0
- data/lib/steep/diagnostic/signature.rb +224 -0
- data/lib/steep/drivers/annotations.rb +13 -6
- data/lib/steep/drivers/check.rb +83 -60
- data/lib/steep/drivers/diagnostic_printer.rb +94 -0
- data/lib/steep/drivers/stats.rb +125 -29
- data/lib/steep/drivers/trace_printer.rb +5 -1
- data/lib/steep/drivers/validate.rb +13 -6
- data/lib/steep/drivers/watch.rb +26 -9
- data/lib/steep/drivers/worker.rb +5 -0
- data/lib/steep/index/rbs_index.rb +334 -0
- data/lib/steep/index/signature_symbol_provider.rb +154 -0
- data/lib/steep/index/source_index.rb +100 -0
- data/lib/steep/interface/block.rb +79 -0
- data/lib/steep/interface/function.rb +770 -0
- data/lib/steep/interface/method_type.rb +32 -812
- data/lib/steep/project/options.rb +4 -4
- data/lib/steep/project/signature_file.rb +8 -2
- data/lib/steep/project/stats_calculator.rb +80 -0
- data/lib/steep/project/target.rb +64 -53
- data/lib/steep/range_extension.rb +29 -0
- data/lib/steep/server/base_worker.rb +42 -4
- data/lib/steep/server/code_worker.rb +37 -24
- data/lib/steep/server/interaction_worker.rb +1 -0
- data/lib/steep/server/master.rb +269 -79
- data/lib/steep/server/signature_worker.rb +70 -65
- data/lib/steep/server/worker_process.rb +9 -9
- data/lib/steep/signature/validator.rb +56 -8
- data/lib/steep/subtyping/check.rb +42 -18
- data/lib/steep/subtyping/variable_occurrence.rb +2 -2
- data/lib/steep/subtyping/variable_variance.rb +2 -2
- data/lib/steep/type_construction.rb +515 -284
- data/lib/steep/type_inference/block_params.rb +1 -1
- data/lib/steep/type_inference/constant_env.rb +5 -1
- data/lib/steep/type_inference/logic_type_interpreter.rb +102 -26
- 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.yaml +73 -0
- data/smoke/and/a.rb +0 -3
- data/smoke/and/test.yaml +24 -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.yaml +80 -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.yaml +96 -0
- data/smoke/broken/Steepfile +5 -0
- data/smoke/broken/broken.rb +0 -0
- data/smoke/broken/broken.rbs +0 -0
- data/smoke/broken/test.yaml +6 -0
- data/smoke/case/a.rb +0 -3
- data/smoke/case/test.yaml +36 -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.yaml +89 -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.yaml +96 -0
- data/smoke/diagnostics-rbs-duplicated/Steepfile +5 -0
- data/smoke/diagnostics-rbs-duplicated/a.rbs +5 -0
- data/smoke/diagnostics-rbs-duplicated/test.yaml +10 -0
- data/smoke/diagnostics-rbs/Steepfile +5 -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.yaml +142 -0
- data/smoke/diagnostics-rbs/unknown-method-alias.rbs +3 -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.yaml +333 -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.yaml +10 -0
- data/smoke/ensure/a.rb +0 -4
- data/smoke/ensure/test.yaml +47 -0
- data/smoke/enumerator/a.rb +0 -6
- data/smoke/enumerator/b.rb +0 -3
- data/smoke/enumerator/test.yaml +100 -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/test.yaml +50 -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.yaml +62 -0
- data/smoke/hello/hello.rb +0 -2
- data/smoke/hello/test.yaml +18 -0
- data/smoke/if/a.rb +0 -2
- data/smoke/if/test.yaml +27 -0
- data/smoke/implements/a.rb +0 -2
- data/smoke/implements/test.yaml +16 -0
- data/smoke/initialize/test.yaml +4 -0
- data/smoke/integer/a.rb +0 -7
- data/smoke/integer/test.yaml +66 -0
- data/smoke/interface/a.rb +0 -2
- data/smoke/interface/test.yaml +16 -0
- data/smoke/kwbegin/a.rb +0 -1
- data/smoke/kwbegin/test.yaml +14 -0
- data/smoke/lambda/a.rb +1 -4
- data/smoke/lambda/test.yaml +28 -0
- data/smoke/literal/a.rb +0 -5
- data/smoke/literal/b.rb +0 -2
- data/smoke/literal/test.yaml +79 -0
- data/smoke/map/test.yaml +4 -0
- data/smoke/method/a.rb +0 -5
- data/smoke/method/b.rb +0 -1
- data/smoke/method/test.yaml +71 -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.yaml +51 -0
- data/smoke/regexp/a.rb +0 -38
- data/smoke/regexp/b.rb +0 -26
- data/smoke/regexp/test.yaml +372 -0
- data/smoke/regression/set_divide.rb +0 -4
- data/smoke/regression/test.yaml +38 -0
- data/smoke/rescue/a.rb +0 -5
- data/smoke/rescue/test.yaml +60 -0
- data/smoke/self/a.rb +0 -2
- data/smoke/self/test.yaml +16 -0
- data/smoke/skip/skip.rb +0 -2
- data/smoke/skip/test.yaml +16 -0
- data/smoke/stdout/test.yaml +4 -0
- data/smoke/super/a.rb +0 -4
- data/smoke/super/test.yaml +52 -0
- data/smoke/toplevel/a.rb +0 -1
- data/smoke/toplevel/test.yaml +12 -0
- data/smoke/tsort/Steepfile +6 -0
- data/smoke/tsort/a.rb +12 -0
- data/smoke/tsort/test.yaml +32 -0
- data/smoke/type_case/a.rb +0 -4
- data/smoke/type_case/test.yaml +33 -0
- data/smoke/yield/a.rb +0 -3
- data/smoke/yield/b.rb +6 -0
- data/smoke/yield/test.yaml +49 -0
- data/steep.gemspec +3 -3
- metadata +116 -18
- 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/signature/errors.rb +0 -82
- data/lib/steep/type_assignability.rb +0 -367
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 725a6432404ca94fa643ba89ed2028d7b3923ece4031512ebea88ebbdc4fd01e
|
4
|
+
data.tar.gz: 957a95acbda38474f1a796f829f8cf098b69484a8ddf42bd39e2c2be935a961e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363a04610a81d4652541c9e5856705f7317a8b4e92a2074dc460b5f34e19f8eb5bfd080826c3a61a41414668d22d0352e4b300d1ce09c659243ef8c06492fc22
|
7
|
+
data.tar.gz: 33b8d47d5290acea68f1f07ee74a6129ad0a2568fff2ddc783b7910f2ed55ae2d6d6b6f0b1b90b8dea773bfab0c9cc7ccc70723ab5aee75db3e3a0f997b93fe9
|
data/.github/workflows/ruby.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,37 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.40.0 (2021-01-31)
|
6
|
+
|
7
|
+
* Report progress with dots ([#287](https://github.com/soutaro/steep/pull/287))
|
8
|
+
* Diagnostics message improvements ([#297](https://github.com/soutaro/steep/pull/297), [#301](https://github.com/soutaro/steep/pull/301))
|
9
|
+
* Fix error on implicit `to_proc` syntax when `untyped` is yielded ([#291](https://github.com/soutaro/steep/pull/291))
|
10
|
+
|
11
|
+
## 0.39.0 (2020-12-25)
|
12
|
+
|
13
|
+
* Update RBS to 1.0.0 ([#282](https://github.com/soutaro/steep/pull/282))
|
14
|
+
* Better `&&` and `||` typing ([#276](https://github.com/soutaro/steep/pull/276))
|
15
|
+
* Type case based on literals ([#277](https://github.com/soutaro/steep/pull/277))
|
16
|
+
* Type case improvements ([#279](https://github.com/soutaro/steep/pull/279), [#283](https://github.com/soutaro/steep/pull/283))
|
17
|
+
* Improvements on untyped classes/modules, unsupported syntax error handling, and argument types in untyped methods ([#280](https://github.com/soutaro/steep/pull/280))
|
18
|
+
* Fix `bot` and `top` type format ([#278](https://github.com/soutaro/steep/pull/278))
|
19
|
+
* Colorfull error messages ([#273](https://github.com/soutaro/steep/pull/273))
|
20
|
+
|
21
|
+
## 0.38.0 (2020-12-10)
|
22
|
+
|
23
|
+
* Improve `break`/`next` typing ([#271](https://github.com/soutaro/steep/pull/271))
|
24
|
+
* Add LSP `workspace/symbol` feature ([#267](https://github.com/soutaro/steep/pull/267))
|
25
|
+
|
26
|
+
## 0.37.0 (2020-12-06)
|
27
|
+
|
28
|
+
* Update to RBS 0.20.0 with _singleton attribute_ syntax and _proc types with blocks_. ([#264](https://github.com/soutaro/steep/pull/264))
|
29
|
+
|
30
|
+
## 0.36.0 (2020-11-16)
|
31
|
+
|
32
|
+
* Flow-sensitive typing improvements with `||` and `&&` ([#260](https://github.com/soutaro/steep/pull/260))
|
33
|
+
* Type-case improvement ([#259](https://github.com/soutaro/steep/pull/259))
|
34
|
+
* Subtyping between `bool` and logic types ([#258](https://github.com/soutaro/steep/pull/258))
|
35
|
+
|
5
36
|
## 0.35.0 (2020-11-14)
|
6
37
|
|
7
38
|
* Support third party RBS repository ([#231](https://github.com/soutaro/steep/pull/231), [#254](https://github.com/soutaro/steep/pull/254), [#255](https://github.com/soutaro/steep/pull/255))
|
data/Rakefile
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "yaml"
|
3
|
+
require "open3"
|
4
|
+
require "tempfile"
|
5
|
+
|
6
|
+
if ARGV.empty?
|
7
|
+
test_dirs = (Pathname(__dir__) + "../smoke").children
|
8
|
+
else
|
9
|
+
test_dirs = ARGV.map {|p| Pathname.pwd + p }
|
10
|
+
end
|
11
|
+
|
12
|
+
test_dirs.each do |dir|
|
13
|
+
test = dir + "test.yaml"
|
14
|
+
|
15
|
+
if test.file?
|
16
|
+
content = YAML.load_file(test)
|
17
|
+
else
|
18
|
+
content = { "test" => {} }
|
19
|
+
end
|
20
|
+
|
21
|
+
puts "Rebaselining #{dir}..."
|
22
|
+
|
23
|
+
command = content["command"] || "steep check"
|
24
|
+
puts " command: #{command}"
|
25
|
+
|
26
|
+
output, _ = Open3.capture2(command, chdir: dir.to_s)
|
27
|
+
|
28
|
+
diagnostics = output.split(/\n\n/).each.with_object({}) do |message, hash|
|
29
|
+
if message =~ /\A([^:]+):\d+:\d+:/
|
30
|
+
path = $1
|
31
|
+
hash[path] ||= { "diagnostics" => [] }
|
32
|
+
hash[path]["diagnostics"] << message.chomp + "\n"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
content["test"].each_key do |path|
|
37
|
+
unless diagnostics.key?(path)
|
38
|
+
diagnostics[path] = { "diagnostics" => [] }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
content["test"] = diagnostics.keys.sort.each.with_object({}) do |key, hash|
|
43
|
+
hash[key] = diagnostics[key]
|
44
|
+
end
|
45
|
+
|
46
|
+
test.open("w") do |io|
|
47
|
+
YAML.dump(content, io, header: false)
|
48
|
+
end
|
49
|
+
end
|
data/bin/output_test.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "yaml"
|
3
|
+
require "open3"
|
4
|
+
require "tempfile"
|
5
|
+
require "optparse"
|
6
|
+
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.on("--verbose", "-v") { @verbose = true }
|
9
|
+
end.parse!(ARGV)
|
10
|
+
|
11
|
+
if ARGV.empty?
|
12
|
+
test_dirs = (Pathname(__dir__) + "../smoke").children
|
13
|
+
else
|
14
|
+
test_dirs = ARGV.map {|p| Pathname.pwd + p }
|
15
|
+
end
|
16
|
+
|
17
|
+
success = true
|
18
|
+
|
19
|
+
test_dirs.each do |dir|
|
20
|
+
test = dir + "test.yaml"
|
21
|
+
|
22
|
+
next unless test.file?
|
23
|
+
|
24
|
+
puts "Running test #{dir}..."
|
25
|
+
|
26
|
+
content = YAML.load_file(test)
|
27
|
+
|
28
|
+
command = content["command"] || "steep check"
|
29
|
+
puts " command: #{command}"
|
30
|
+
|
31
|
+
output, _ = Open3.capture2(command, chdir: dir.to_s)
|
32
|
+
|
33
|
+
if @verbose
|
34
|
+
puts " Raw output:"
|
35
|
+
output.split(/\n/).each do |line|
|
36
|
+
puts " > #{line.chomp}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
diagnostics = output.split(/\n\n/).each.with_object({}) do |d, hash|
|
41
|
+
if d =~ /\A([^:]+):\d+:\d+:/
|
42
|
+
path = $1
|
43
|
+
hash[path] ||= []
|
44
|
+
hash[path] << (d.chomp + "\n")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
content["test"].each do |path, test|
|
49
|
+
puts " Checking: #{path}..."
|
50
|
+
|
51
|
+
fail_expected = test["fail"] || false
|
52
|
+
|
53
|
+
expected_diagnostics = test["diagnostics"]
|
54
|
+
reported_diagnostics = (diagnostics[path] || [])
|
55
|
+
|
56
|
+
puts " # of expected: #{expected_diagnostics.size}, # of reported: #{reported_diagnostics.size}"
|
57
|
+
|
58
|
+
unexpected_diagnostics = reported_diagnostics.reject {|d| expected_diagnostics.include?(d) }
|
59
|
+
missing_diagnostics = expected_diagnostics.reject {|d| reported_diagnostics.include?(d) }
|
60
|
+
|
61
|
+
unexpected_diagnostics.each do |d|
|
62
|
+
puts " Unexpected diagnostics:"
|
63
|
+
d.split(/\n/).each do |line|
|
64
|
+
puts " + #{line.chomp}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
missing_diagnostics.each do |d|
|
69
|
+
puts " Missing diagnostics:"
|
70
|
+
d.split(/\n/).each do |line|
|
71
|
+
puts " - #{line.chomp}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if unexpected_diagnostics.empty? && missing_diagnostics.empty?
|
76
|
+
puts " 👍"
|
77
|
+
else
|
78
|
+
if fail_expected
|
79
|
+
puts " 🚨 (expected failure)"
|
80
|
+
else
|
81
|
+
puts " 🚨"
|
82
|
+
success = false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if success
|
89
|
+
puts "All tests ok! 👏"
|
90
|
+
else
|
91
|
+
puts "Errors detected! 🤮"
|
92
|
+
exit 1
|
93
|
+
end
|
data/lib/steep.rb
CHANGED
@@ -42,6 +42,10 @@ require "steep/ast/annotation/collection"
|
|
42
42
|
require "steep/ast/builtin"
|
43
43
|
require "steep/ast/types/factory"
|
44
44
|
|
45
|
+
require "steep/range_extension"
|
46
|
+
|
47
|
+
require "steep/interface/function"
|
48
|
+
require "steep/interface/block"
|
45
49
|
require "steep/interface/method_type"
|
46
50
|
require "steep/interface/substitution"
|
47
51
|
require "steep/interface/interface"
|
@@ -54,12 +58,14 @@ require "steep/subtyping/constraints"
|
|
54
58
|
require "steep/subtyping/variable_variance"
|
55
59
|
require "steep/subtyping/variable_occurrence"
|
56
60
|
|
57
|
-
require "steep/
|
61
|
+
require "steep/diagnostic/helper"
|
62
|
+
require "steep/diagnostic/ruby"
|
63
|
+
require "steep/diagnostic/signature"
|
64
|
+
require "steep/diagnostic/lsp_formatter"
|
58
65
|
require "steep/signature/validator"
|
59
66
|
require "steep/source"
|
60
67
|
require "steep/annotation_parser"
|
61
68
|
require "steep/typing"
|
62
|
-
require "steep/errors"
|
63
69
|
require "steep/module_helper"
|
64
70
|
require "steep/type_construction"
|
65
71
|
require "steep/type_inference/context"
|
@@ -74,6 +80,10 @@ require "steep/type_inference/logic_type_interpreter"
|
|
74
80
|
require "steep/type_inference/method_call"
|
75
81
|
require "steep/ast/types"
|
76
82
|
|
83
|
+
require "steep/index/rbs_index"
|
84
|
+
require "steep/index/signature_symbol_provider"
|
85
|
+
require "steep/index/source_index"
|
86
|
+
|
77
87
|
require "steep/server/utils"
|
78
88
|
require "steep/server/base_worker"
|
79
89
|
require "steep/server/code_worker"
|
@@ -91,6 +101,7 @@ require "steep/project/dsl"
|
|
91
101
|
require "steep/project/file_loader"
|
92
102
|
require "steep/project/hover_content"
|
93
103
|
require "steep/project/completion_provider"
|
104
|
+
require "steep/project/stats_calculator"
|
94
105
|
require "steep/drivers/utils/driver_helper"
|
95
106
|
require "steep/drivers/check"
|
96
107
|
require "steep/drivers/stats"
|
@@ -98,12 +109,12 @@ require "steep/drivers/validate"
|
|
98
109
|
require "steep/drivers/annotations"
|
99
110
|
require "steep/drivers/watch"
|
100
111
|
require "steep/drivers/langserver"
|
101
|
-
require "steep/drivers/signature_error_printer"
|
102
112
|
require "steep/drivers/trace_printer"
|
103
113
|
require "steep/drivers/print_project"
|
104
114
|
require "steep/drivers/init"
|
105
115
|
require "steep/drivers/vendor"
|
106
116
|
require "steep/drivers/worker"
|
117
|
+
require "steep/drivers/diagnostic_printer"
|
107
118
|
|
108
119
|
if ENV["NO_COLOR"]
|
109
120
|
Rainbow.enabled = false
|
data/lib/steep/ast/types/bot.rb
CHANGED
@@ -75,9 +75,23 @@ module Steep
|
|
75
75
|
end
|
76
76
|
Record.new(elements: elements, location: nil)
|
77
77
|
when RBS::Types::Proc
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
func = Interface::Function.new(
|
79
|
+
params: params(type.type),
|
80
|
+
return_type: type(type.type.return_type),
|
81
|
+
location: type.location
|
82
|
+
)
|
83
|
+
block = if type.block
|
84
|
+
Interface::Block.new(
|
85
|
+
type: Interface::Function.new(
|
86
|
+
params: params(type.block.type),
|
87
|
+
return_type: type(type.block.type.return_type),
|
88
|
+
location: type.location
|
89
|
+
),
|
90
|
+
optional: !type.block.required
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
Proc.new(type: func, block: block)
|
81
95
|
else
|
82
96
|
raise "Unexpected type given: #{type}"
|
83
97
|
end
|
@@ -145,8 +159,15 @@ module Steep
|
|
145
159
|
end
|
146
160
|
RBS::Types::Record.new(fields: fields, location: nil)
|
147
161
|
when Proc
|
162
|
+
block = if type.block
|
163
|
+
RBS::Types::Block.new(
|
164
|
+
type: function_1(type.block.type),
|
165
|
+
required: !type.block.optional?
|
166
|
+
)
|
167
|
+
end
|
148
168
|
RBS::Types::Proc.new(
|
149
|
-
type: function_1(type.
|
169
|
+
type: function_1(type.type),
|
170
|
+
block: block,
|
150
171
|
location: nil
|
151
172
|
)
|
152
173
|
when Logic::Base
|
@@ -156,7 +177,10 @@ module Steep
|
|
156
177
|
end
|
157
178
|
end
|
158
179
|
|
159
|
-
def function_1(
|
180
|
+
def function_1(func)
|
181
|
+
params = func.params
|
182
|
+
return_type = func.return_type
|
183
|
+
|
160
184
|
RBS::Types::Function.new(
|
161
185
|
required_positionals: params.required.map {|type| RBS::Types::Function::Param.new(name: nil, type: type_1(type)) },
|
162
186
|
optional_positionals: params.optional.map {|type| RBS::Types::Function::Param.new(name: nil, type: type_1(type)) },
|
@@ -170,7 +194,7 @@ module Steep
|
|
170
194
|
end
|
171
195
|
|
172
196
|
def params(type)
|
173
|
-
Interface::Params.new(
|
197
|
+
Interface::Function::Params.new(
|
174
198
|
required: type.required_positionals.map {|param| type(param.type) },
|
175
199
|
optional: type.optional_positionals.map {|param| type(param.type) },
|
176
200
|
rest: type.rest_positionals&.yield_self {|param| type(param.type) },
|
@@ -202,13 +226,19 @@ module Steep
|
|
202
226
|
|
203
227
|
type = Interface::MethodType.new(
|
204
228
|
type_params: type_params,
|
205
|
-
|
206
|
-
|
229
|
+
type: Interface::Function.new(
|
230
|
+
params: params(method_type.type).subst(subst),
|
231
|
+
return_type: type(method_type.type.return_type).subst(subst),
|
232
|
+
location: method_type.location
|
233
|
+
),
|
207
234
|
block: method_type.block&.yield_self do |block|
|
208
235
|
Interface::Block.new(
|
209
236
|
optional: !block.required,
|
210
|
-
type:
|
211
|
-
|
237
|
+
type: Interface::Function.new(
|
238
|
+
params: params(block.type).subst(subst),
|
239
|
+
return_type: type(block.type.return_type).subst(subst),
|
240
|
+
location: nil
|
241
|
+
)
|
212
242
|
)
|
213
243
|
end,
|
214
244
|
method_decls: method_decls
|
@@ -242,12 +272,12 @@ module Steep
|
|
242
272
|
|
243
273
|
type = RBS::MethodType.new(
|
244
274
|
type_params: type_params,
|
245
|
-
type: function_1(method_type.
|
275
|
+
type: function_1(method_type.type.subst(subst)),
|
246
276
|
block: method_type.block&.yield_self do |block|
|
247
277
|
block_type = block.type.subst(subst)
|
248
278
|
|
249
|
-
RBS::
|
250
|
-
type: function_1(block_type
|
279
|
+
RBS::Types::Block.new(
|
280
|
+
type: function_1(block_type),
|
251
281
|
required: !block.optional
|
252
282
|
)
|
253
283
|
end,
|
@@ -338,6 +368,8 @@ module Steep
|
|
338
368
|
]
|
339
369
|
when AST::Types::Name::Alias
|
340
370
|
unwrap_optional(expand_alias(type))
|
371
|
+
when AST::Types::Boolean
|
372
|
+
[AST::Builtin.true_type, AST::Builtin.false_type]
|
341
373
|
else
|
342
374
|
[type, nil]
|
343
375
|
end
|
@@ -354,7 +386,9 @@ module Steep
|
|
354
386
|
when :is_a?, :kind_of?, :instance_of?
|
355
387
|
if defined_in == RBS::BuiltinNames::Object.name && member.instance?
|
356
388
|
return method_type.with(
|
357
|
-
|
389
|
+
type: method_type.type.with(
|
390
|
+
return_type: AST::Types::Logic::ReceiverIsArg.new(location: method_type.type.return_type.location)
|
391
|
+
)
|
358
392
|
)
|
359
393
|
end
|
360
394
|
|
@@ -363,7 +397,9 @@ module Steep
|
|
363
397
|
when RBS::BuiltinNames::Object.name,
|
364
398
|
NilClassName
|
365
399
|
return method_type.with(
|
366
|
-
|
400
|
+
type: method_type.type.with(
|
401
|
+
return_type: AST::Types::Logic::ReceiverIsNil.new(location: method_type.type.return_type.location)
|
402
|
+
)
|
367
403
|
)
|
368
404
|
end
|
369
405
|
|
@@ -373,7 +409,9 @@ module Steep
|
|
373
409
|
RBS::BuiltinNames::TrueClass.name,
|
374
410
|
RBS::BuiltinNames::FalseClass.name
|
375
411
|
return method_type.with(
|
376
|
-
|
412
|
+
type: method_type.type.with(
|
413
|
+
return_type: AST::Types::Logic::Not.new(location: method_type.type.return_type.location)
|
414
|
+
)
|
377
415
|
)
|
378
416
|
end
|
379
417
|
|
@@ -381,7 +419,17 @@ module Steep
|
|
381
419
|
case defined_in
|
382
420
|
when RBS::BuiltinNames::Module.name
|
383
421
|
return method_type.with(
|
384
|
-
|
422
|
+
type: method_type.type.with(
|
423
|
+
return_type: AST::Types::Logic::ArgIsReceiver.new(location: method_type.type.return_type.location)
|
424
|
+
)
|
425
|
+
)
|
426
|
+
when RBS::BuiltinNames::Object.name, RBS::BuiltinNames::String.name, RBS::BuiltinNames::Integer.name, RBS::BuiltinNames::Symbol.name,
|
427
|
+
RBS::BuiltinNames::TrueClass.name, RBS::BuiltinNames::FalseClass.name, TypeName("::NilClass")
|
428
|
+
# Value based type-case works on literal types which is available for String, Integer, Symbol, TrueClass, FalseClass, and NilClass
|
429
|
+
return method_type.with(
|
430
|
+
type: method_type.type.with(
|
431
|
+
return_type: AST::Types::Logic::ArgEqualsReceiver.new(location: method_type.type.return_type.location)
|
432
|
+
)
|
385
433
|
)
|
386
434
|
end
|
387
435
|
end
|
@@ -572,14 +620,17 @@ module Steep
|
|
572
620
|
method_types: type.types.map.with_index {|elem_type, index|
|
573
621
|
Interface::MethodType.new(
|
574
622
|
type_params: [],
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
623
|
+
type: Interface::Function.new(
|
624
|
+
params: Interface::Function::Params.new(required: [AST::Types::Literal.new(value: index)],
|
625
|
+
optional: [],
|
626
|
+
rest: nil,
|
627
|
+
required_keywords: {},
|
628
|
+
optional_keywords: {},
|
629
|
+
rest_keywords: nil),
|
630
|
+
return_type: elem_type,
|
631
|
+
location: nil
|
632
|
+
),
|
581
633
|
block: nil,
|
582
|
-
return_type: elem_type,
|
583
634
|
method_decls: Set[]
|
584
635
|
)
|
585
636
|
} + aref.method_types
|
@@ -591,14 +642,17 @@ module Steep
|
|
591
642
|
method_types: type.types.map.with_index {|elem_type, index|
|
592
643
|
Interface::MethodType.new(
|
593
644
|
type_params: [],
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
645
|
+
type: Interface::Function.new(
|
646
|
+
params: Interface::Function::Params.new(required: [AST::Types::Literal.new(value: index), elem_type],
|
647
|
+
optional: [],
|
648
|
+
rest: nil,
|
649
|
+
required_keywords: {},
|
650
|
+
optional_keywords: {},
|
651
|
+
rest_keywords: nil),
|
652
|
+
return_type: elem_type,
|
653
|
+
location: nil
|
654
|
+
),
|
600
655
|
block: nil,
|
601
|
-
return_type: elem_type,
|
602
656
|
method_decls: Set[]
|
603
657
|
)
|
604
658
|
} + update.method_types
|
@@ -610,9 +664,12 @@ module Steep
|
|
610
664
|
method_types: [
|
611
665
|
Interface::MethodType.new(
|
612
666
|
type_params: [],
|
613
|
-
|
667
|
+
type: Interface::Function.new(
|
668
|
+
params: Interface::Function::Params.empty,
|
669
|
+
return_type: type.types[0] || AST::Builtin.nil_type,
|
670
|
+
location: nil
|
671
|
+
),
|
614
672
|
block: nil,
|
615
|
-
return_type: type.types[0] || AST::Builtin.nil_type,
|
616
673
|
method_decls: Set[]
|
617
674
|
)
|
618
675
|
]
|
@@ -624,9 +681,12 @@ module Steep
|
|
624
681
|
method_types: [
|
625
682
|
Interface::MethodType.new(
|
626
683
|
type_params: [],
|
627
|
-
|
684
|
+
type: Interface::Function.new(
|
685
|
+
params: Interface::Function::Params.empty,
|
686
|
+
return_type: type.types.last || AST::Builtin.nil_type,
|
687
|
+
location: nil
|
688
|
+
),
|
628
689
|
block: nil,
|
629
|
-
return_type: type.types.last || AST::Builtin.nil_type,
|
630
690
|
method_decls: Set[]
|
631
691
|
)
|
632
692
|
]
|
@@ -651,14 +711,17 @@ module Steep
|
|
651
711
|
|
652
712
|
Interface::MethodType.new(
|
653
713
|
type_params: [],
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
714
|
+
type: Interface::Function.new(
|
715
|
+
params: Interface::Function::Params.new(required: [key_type],
|
716
|
+
optional: [],
|
717
|
+
rest: nil,
|
718
|
+
required_keywords: {},
|
719
|
+
optional_keywords: {},
|
720
|
+
rest_keywords: nil),
|
721
|
+
return_type: value_type,
|
722
|
+
location: nil
|
723
|
+
),
|
660
724
|
block: nil,
|
661
|
-
return_type: value_type,
|
662
725
|
method_decls: Set[]
|
663
726
|
)
|
664
727
|
} + ref.method_types
|
@@ -671,14 +734,16 @@ module Steep
|
|
671
734
|
key_type = Literal.new(value: key_value, location: nil)
|
672
735
|
Interface::MethodType.new(
|
673
736
|
type_params: [],
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
737
|
+
type: Interface::Function.new(
|
738
|
+
params: Interface::Function::Params.new(required: [key_type, value_type],
|
739
|
+
optional: [],
|
740
|
+
rest: nil,
|
741
|
+
required_keywords: {},
|
742
|
+
optional_keywords: {},
|
743
|
+
rest_keywords: nil),
|
744
|
+
return_type: value_type,
|
745
|
+
location: nil),
|
680
746
|
block: nil,
|
681
|
-
return_type: value_type,
|
682
747
|
method_decls: Set[]
|
683
748
|
)
|
684
749
|
} + update.method_types
|
@@ -691,14 +756,18 @@ module Steep
|
|
691
756
|
interface(Builtin::Proc.instance_type, private: private, self_type: self_type).tap do |interface|
|
692
757
|
method_type = Interface::MethodType.new(
|
693
758
|
type_params: [],
|
694
|
-
|
695
|
-
|
696
|
-
block: nil,
|
759
|
+
type: type.type,
|
760
|
+
block: type.block,
|
697
761
|
method_decls: Set[]
|
698
762
|
)
|
699
763
|
|
700
|
-
interface.methods[:[]] = Interface::Interface::Entry.new(method_types: [method_type])
|
701
764
|
interface.methods[:call] = Interface::Interface::Entry.new(method_types: [method_type])
|
765
|
+
|
766
|
+
if type.block_required?
|
767
|
+
interface.methods.delete(:[])
|
768
|
+
else
|
769
|
+
interface.methods[:[]] = Interface::Interface::Entry.new(method_types: [method_type.with(block: nil)])
|
770
|
+
end
|
702
771
|
end
|
703
772
|
|
704
773
|
when Logic::Base
|