steep 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -4
- data/Gemfile.steep +0 -3
- data/Steepfile +2 -3
- data/bin/rbs +1 -1
- data/bin/setup +1 -1
- data/bin/steep +1 -1
- data/gemfile_steep/Gemfile +3 -0
- data/{Gemfile.steep.lock → gemfile_steep/Gemfile.lock} +12 -9
- data/lib/steep/ast/annotation/collection.rb +6 -6
- data/lib/steep/diagnostic/ruby.rb +22 -2
- data/lib/steep/drivers/checkfile.rb +1 -2
- data/lib/steep/drivers/stats.rb +1 -1
- data/lib/steep/interface/builder.rb +28 -8
- data/lib/steep/interface/function.rb +8 -8
- data/lib/steep/project/dsl.rb +2 -2
- data/lib/steep/server/interaction_worker.rb +2 -2
- data/lib/steep/services/completion_provider.rb +3 -0
- data/lib/steep/subtyping/check.rb +2 -2
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/type_construction.rb +7 -3
- data/lib/steep/type_inference/logic_type_interpreter.rb +16 -4
- data/lib/steep/type_inference/type_env.rb +3 -3
- data/lib/steep/version.rb +1 -1
- data/rbs_collection.steep.lock.yaml +1 -1
- data/sample/lib/conference.rb +5 -0
- data/sig/steep/ast/annotation/collection.rbs +25 -22
- data/sig/steep/diagnostic/ruby.rbs +2 -4
- data/sig/steep/interface/builder.rbs +12 -0
- data/sig/steep/type_inference/logic_type_interpreter.rbs +4 -0
- data/smoke/unexpected/test_expectations.yml +0 -12
- metadata +4 -6
- data/lib/steep/ast/type_params.rb +0 -13
- data/sig/steep/ast/type_params.rbs +0 -11
- data/smoke/unexpected/unexpected.rb +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2971f6bf7e70b227ac38de9682f640c8b274d8c27db2e02ec6920163d9e26df
|
|
4
|
+
data.tar.gz: 6f756247c85e018f5b2feaac36238480438495d242994f9dd23ccacd52e195d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4ae7293b7ba2f8a33c96e470346f853f83afff373f5724a094c788841602cff54ad911ea74d73cc63471383f8fe043b217fef6528d4d6a6d91cb3351dc358e7
|
|
7
|
+
data.tar.gz: 720040f41d6a7c0fa11facd1bc0b8e0860cd54d3572fd698807894ff6c4fe33beea6c9fff8a4a1bd115e3b494021590ef33bfcd7035556a46cbcc00455943292
|
data/.github/dependabot.yml
CHANGED
|
@@ -8,6 +8,13 @@ updates:
|
|
|
8
8
|
time: "20:00"
|
|
9
9
|
open-pull-requests-limit: 10
|
|
10
10
|
|
|
11
|
+
- package-ecosystem: bundler
|
|
12
|
+
directory: "/gemfile_steep"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: daily
|
|
15
|
+
time: "20:00"
|
|
16
|
+
open-pull-requests-limit: 10
|
|
17
|
+
|
|
11
18
|
- package-ecosystem: "github-actions"
|
|
12
19
|
directory: "/"
|
|
13
20
|
schedule:
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
## master
|
|
4
4
|
|
|
5
|
+
## 1.5.2 (2023-07-27)
|
|
6
|
+
|
|
7
|
+
### Type checker core
|
|
8
|
+
|
|
9
|
+
* Avoid inifinite loop in `#shape` ([#884](https://github.com/soutaro/steep/pull/884))
|
|
10
|
+
* Fix `nil?` typing with `untyped` receiver ([#882](https://github.com/soutaro/steep/pull/882))
|
|
11
|
+
|
|
12
|
+
### Language server
|
|
13
|
+
|
|
14
|
+
* Avoid breaking the original source code through `CompletionProvider` ([#883](https://github.com/soutaro/steep/pull/883))
|
|
15
|
+
|
|
16
|
+
## 1.5.1 (2023-07-20)
|
|
17
|
+
|
|
18
|
+
### Type checker core
|
|
19
|
+
|
|
20
|
+
* Support unreachable branch detection with `elsif` ([#879](https://github.com/soutaro/steep/pull/879))
|
|
21
|
+
* Give an optional type hint to lhs of `||` ([#874](https://github.com/soutaro/steep/pull/874))
|
|
22
|
+
|
|
23
|
+
### Miscellaneous
|
|
24
|
+
|
|
25
|
+
* Update steep ([#878](https://github.com/soutaro/steep/pull/878))
|
|
26
|
+
* Update inline type comments ([#875](https://github.com/soutaro/steep/pull/875))
|
|
27
|
+
|
|
5
28
|
## 1.5.0 (2023-07-13)
|
|
6
29
|
|
|
7
30
|
### Type checker core
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
steep (1.5.
|
|
4
|
+
steep (1.5.2)
|
|
5
5
|
activesupport (>= 5.1)
|
|
6
6
|
concurrent-ruby (>= 1.1.10)
|
|
7
7
|
csv (>= 3.0.9)
|
|
@@ -38,7 +38,7 @@ GEM
|
|
|
38
38
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
39
39
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
40
40
|
logger (1.5.3)
|
|
41
|
-
minitest (5.
|
|
41
|
+
minitest (5.19.0)
|
|
42
42
|
minitest-hooks (1.5.0)
|
|
43
43
|
minitest (> 5.3)
|
|
44
44
|
minitest-slow_test (0.2.0)
|
|
@@ -53,7 +53,7 @@ GEM
|
|
|
53
53
|
rb-fsevent (0.11.2)
|
|
54
54
|
rb-inotify (0.10.1)
|
|
55
55
|
ffi (~> 1.0)
|
|
56
|
-
rbs (3.1.
|
|
56
|
+
rbs (3.1.1)
|
|
57
57
|
ruby-lsp (0.5.1)
|
|
58
58
|
language_server-protocol (~> 3.17.0)
|
|
59
59
|
sorbet-runtime
|
|
@@ -74,7 +74,7 @@ PLATFORMS
|
|
|
74
74
|
ruby
|
|
75
75
|
|
|
76
76
|
DEPENDENCIES
|
|
77
|
-
minitest (~> 5.
|
|
77
|
+
minitest (~> 5.19)
|
|
78
78
|
minitest-hooks
|
|
79
79
|
minitest-slow_test
|
|
80
80
|
rake
|
data/Gemfile.steep
CHANGED
data/Steepfile
CHANGED
|
@@ -3,13 +3,12 @@ D = Steep::Diagnostic
|
|
|
3
3
|
target :app do
|
|
4
4
|
check "lib"
|
|
5
5
|
ignore "lib/steep/shims"
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
signature "sig"
|
|
8
8
|
|
|
9
9
|
collection_config "rbs_collection.steep.yaml"
|
|
10
10
|
|
|
11
|
-
configure_code_diagnostics do |hash|
|
|
12
|
-
hash[D::Ruby::MethodDefinitionMissing] = :hint
|
|
11
|
+
configure_code_diagnostics(D::Ruby.strict) do |hash|
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
FileUtils.mkpath("tmp")
|
data/bin/rbs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
BINSTUB_DIR=$(cd $(dirname $0); pwd)
|
|
4
|
-
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../Gemfile
|
|
4
|
+
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../gemfile_steep/Gemfile)
|
|
5
5
|
COLLECTION=$(readlink -f ${BINSTUB_DIR}/../rbs_collection.steep.yaml)
|
|
6
6
|
ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)
|
|
7
7
|
|
data/bin/setup
CHANGED
data/bin/steep
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
BINSTUB_DIR=$(cd $(dirname $0); pwd)
|
|
4
|
-
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../Gemfile
|
|
4
|
+
GEMFILE=$(readlink -f ${BINSTUB_DIR}/../gemfile_steep/Gemfile)
|
|
5
5
|
ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)
|
|
6
6
|
|
|
7
7
|
STEEP="bundle exec --gemfile=${GEMFILE} steep"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
activesupport (7.0.
|
|
4
|
+
activesupport (7.0.6)
|
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
6
6
|
i18n (>= 1.6, < 2)
|
|
7
7
|
minitest (>= 5.1)
|
|
8
8
|
tzinfo (~> 2.0)
|
|
9
9
|
ast (2.4.2)
|
|
10
10
|
concurrent-ruby (1.2.2)
|
|
11
|
-
csv (3.2.
|
|
11
|
+
csv (3.2.7)
|
|
12
12
|
ffi (1.15.5)
|
|
13
13
|
fileutils (1.7.1)
|
|
14
|
-
i18n (1.
|
|
14
|
+
i18n (1.14.1)
|
|
15
15
|
concurrent-ruby (~> 1.0)
|
|
16
16
|
json (2.6.3)
|
|
17
17
|
language_server-protocol (3.17.0.3)
|
|
@@ -19,18 +19,20 @@ GEM
|
|
|
19
19
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
20
20
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
21
21
|
logger (1.5.3)
|
|
22
|
-
minitest (5.18.
|
|
23
|
-
parser (3.2.2.
|
|
22
|
+
minitest (5.18.1)
|
|
23
|
+
parser (3.2.2.3)
|
|
24
24
|
ast (~> 2.4.1)
|
|
25
|
+
racc
|
|
26
|
+
racc (1.7.1)
|
|
25
27
|
rainbow (3.1.1)
|
|
26
28
|
rb-fsevent (0.11.2)
|
|
27
29
|
rb-inotify (0.10.1)
|
|
28
30
|
ffi (~> 1.0)
|
|
29
|
-
rbs (3.1.
|
|
31
|
+
rbs (3.1.1)
|
|
30
32
|
securerandom (0.2.2)
|
|
31
|
-
steep (1.
|
|
33
|
+
steep (1.5.1)
|
|
32
34
|
activesupport (>= 5.1)
|
|
33
|
-
concurrent-ruby (>= 1.
|
|
35
|
+
concurrent-ruby (>= 1.1.10)
|
|
34
36
|
csv (>= 3.0.9)
|
|
35
37
|
fileutils (>= 1.1.0)
|
|
36
38
|
json (>= 2.1.0)
|
|
@@ -39,7 +41,7 @@ GEM
|
|
|
39
41
|
logger (>= 1.3.0)
|
|
40
42
|
parser (>= 3.1)
|
|
41
43
|
rainbow (>= 2.2.2, < 4.0)
|
|
42
|
-
rbs (>=
|
|
44
|
+
rbs (>= 3.1.0)
|
|
43
45
|
securerandom (>= 0.1)
|
|
44
46
|
strscan (>= 1.0.0)
|
|
45
47
|
terminal-table (>= 2, < 4)
|
|
@@ -53,6 +55,7 @@ GEM
|
|
|
53
55
|
PLATFORMS
|
|
54
56
|
arm64-darwin-21
|
|
55
57
|
arm64-darwin-22
|
|
58
|
+
x86_64-linux
|
|
56
59
|
|
|
57
60
|
DEPENDENCIES
|
|
58
61
|
steep
|
|
@@ -110,20 +110,20 @@ module Steep
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def lvar_types
|
|
113
|
-
var_type_annotations.each_key.with_object({}) do |name, hash|
|
|
114
|
-
hash[name] = var_type(lvar: name)
|
|
113
|
+
var_type_annotations.each_key.with_object({}) do |name, hash| #$ Hash[Symbol, Types::t]
|
|
114
|
+
hash[name] = var_type(lvar: name) || raise
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
def ivar_types
|
|
119
|
-
ivar_type_annotations.each_key.with_object({}) do |name, hash|
|
|
120
|
-
hash[name] = var_type(ivar: name)
|
|
119
|
+
ivar_type_annotations.each_key.with_object({}) do |name, hash| #$ Hash[Symbol, Types::t]
|
|
120
|
+
hash[name] = var_type(ivar: name) || raise
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
def const_types
|
|
125
|
-
const_type_annotations.each_key.with_object({}) do |name, hash|
|
|
126
|
-
hash[name] = var_type(const: name)
|
|
125
|
+
const_type_annotations.each_key.with_object({}) do |name, hash| #$ Hash[RBS::TypeName, Types::t]
|
|
126
|
+
hash[name] = var_type(const: name) || raise
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -841,7 +841,6 @@ module Steep
|
|
|
841
841
|
end
|
|
842
842
|
|
|
843
843
|
class UnexpectedError < Base
|
|
844
|
-
attr_reader :message
|
|
845
844
|
attr_reader :error
|
|
846
845
|
|
|
847
846
|
def initialize(node:, error:)
|
|
@@ -850,7 +849,28 @@ module Steep
|
|
|
850
849
|
end
|
|
851
850
|
|
|
852
851
|
def header_line
|
|
853
|
-
"UnexpectedError: #{error.message}"
|
|
852
|
+
"UnexpectedError: #{error.message}(#{error.class})"
|
|
853
|
+
end
|
|
854
|
+
|
|
855
|
+
def detail_lines
|
|
856
|
+
if trace = error.backtrace
|
|
857
|
+
io = StringIO.new
|
|
858
|
+
|
|
859
|
+
total = trace.size
|
|
860
|
+
if total > 30
|
|
861
|
+
trace = trace.take(15)
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
trace.each.with_index do |line, index|
|
|
865
|
+
io.puts "#{index+1}. #{line}"
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
if trace.size != total
|
|
869
|
+
io.puts " (#{total - trace.size} more backtrace)"
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
io.string
|
|
873
|
+
end
|
|
854
874
|
end
|
|
855
875
|
end
|
|
856
876
|
|
|
@@ -168,8 +168,7 @@ module Steep
|
|
|
168
168
|
|
|
169
169
|
Steep.logger.info { "Starting type checking: #{request_guid}" }
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
error_messages = []
|
|
171
|
+
error_messages = [] #: Array[String]
|
|
173
172
|
client_reader.read do |response|
|
|
174
173
|
case
|
|
175
174
|
when response[:method] == "textDocument/publishDiagnostics"
|
data/lib/steep/drivers/stats.rb
CHANGED
|
@@ -68,6 +68,24 @@ module Steep
|
|
|
68
68
|
)
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
+
|
|
72
|
+
def self_type?
|
|
73
|
+
unless self_type.is_a?(AST::Types::Self)
|
|
74
|
+
self_type
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def instance_type?
|
|
79
|
+
unless instance_type.is_a?(AST::Types::Instance)
|
|
80
|
+
instance_type
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def class_type?
|
|
85
|
+
unless class_type.is_a?(AST::Types::Class)
|
|
86
|
+
class_type
|
|
87
|
+
end
|
|
88
|
+
end
|
|
71
89
|
end
|
|
72
90
|
|
|
73
91
|
attr_reader :factory, :cache, :raw_object_cache
|
|
@@ -122,16 +140,18 @@ module Steep
|
|
|
122
140
|
fetch_cache(type, public_only, config) do
|
|
123
141
|
case type
|
|
124
142
|
when AST::Types::Self
|
|
125
|
-
self_type = config.self_type
|
|
126
|
-
|
|
143
|
+
if self_type = config.self_type?
|
|
144
|
+
self_type = self_type.subst(config.subst)
|
|
145
|
+
shape(self_type, public_only: public_only, config: config.update(resolve_self: false))
|
|
146
|
+
end
|
|
127
147
|
when AST::Types::Instance
|
|
128
|
-
if config.instance_type
|
|
129
|
-
instance_type =
|
|
148
|
+
if instance_type = config.instance_type?
|
|
149
|
+
instance_type = instance_type.subst(config.subst)
|
|
130
150
|
shape(instance_type, public_only: public_only, config: config.update(resolve_instance: false))
|
|
131
151
|
end
|
|
132
152
|
when AST::Types::Class
|
|
133
|
-
if config.class_type
|
|
134
|
-
class_type =
|
|
153
|
+
if class_type = config.class_type?
|
|
154
|
+
class_type = class_type.subst(config.subst)
|
|
135
155
|
shape(class_type, public_only: public_only, config: config.update(resolve_class: false))
|
|
136
156
|
end
|
|
137
157
|
when AST::Types::Name::Instance, AST::Types::Name::Interface, AST::Types::Name::Singleton
|
|
@@ -159,7 +179,7 @@ module Steep
|
|
|
159
179
|
instance_var = AST::Types::Var.fresh(:INSTANCE)
|
|
160
180
|
|
|
161
181
|
bounds = config.variable_bounds.merge({ self_var.name => config.self_type, instance_var.name => config.instance_type, class_var.name => config.class_type })
|
|
162
|
-
type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var))
|
|
182
|
+
type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var)) #: AST::Types::Union
|
|
163
183
|
|
|
164
184
|
config_ = config.update(resolve_self: false, resolve_class: true, resolve_instance: true, variable_bounds: bounds)
|
|
165
185
|
|
|
@@ -203,7 +223,7 @@ module Steep
|
|
|
203
223
|
instance_var = AST::Types::Var.fresh(:INSTANCE)
|
|
204
224
|
|
|
205
225
|
bounds = config.variable_bounds.merge({ self_var.name => config.self_type, instance_var.name => config.instance_type, class_var.name => config.class_type })
|
|
206
|
-
type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var))
|
|
226
|
+
type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var)) #: AST::Types::Intersection
|
|
207
227
|
|
|
208
228
|
config_ = config.update(resolve_self: false, resolve_class: true, resolve_instance: true, variable_bounds: bounds)
|
|
209
229
|
|
|
@@ -471,8 +471,8 @@ module Steep
|
|
|
471
471
|
|
|
472
472
|
# For overloading
|
|
473
473
|
def +(other)
|
|
474
|
-
requireds = {}
|
|
475
|
-
optionals = {}
|
|
474
|
+
requireds = {} #: Hash[Symbol, AST::Types::t]
|
|
475
|
+
optionals = {} #: Hash[Symbol, AST::Types::t]
|
|
476
476
|
|
|
477
477
|
all_keys = Set[] + self.requireds.keys + self.optionals.keys + other.requireds.keys + other.optionals.keys
|
|
478
478
|
all_keys.each do |key|
|
|
@@ -535,8 +535,8 @@ module Steep
|
|
|
535
535
|
|
|
536
536
|
# For union
|
|
537
537
|
def |(other)
|
|
538
|
-
requireds = {}
|
|
539
|
-
optionals = {}
|
|
538
|
+
requireds = {} #: Hash[Symbol, AST::Types::t]
|
|
539
|
+
optionals = {} #: Hash[Symbol, AST::Types::t]
|
|
540
540
|
|
|
541
541
|
all_keys = Set[] + self.requireds.keys + self.optionals.keys + other.requireds.keys + other.optionals.keys
|
|
542
542
|
all_keys.each do |key|
|
|
@@ -600,8 +600,8 @@ module Steep
|
|
|
600
600
|
|
|
601
601
|
# For intersection
|
|
602
602
|
def &(other)
|
|
603
|
-
requireds = {}
|
|
604
|
-
optionals = {}
|
|
603
|
+
requireds = {} #: Hash[Symbol, AST::Types::t]
|
|
604
|
+
optionals = {} #: Hash[Symbol, AST::Types::t]
|
|
605
605
|
|
|
606
606
|
all_keys = Set[] + self.requireds.keys + self.optionals.keys + other.requireds.keys + other.optionals.keys
|
|
607
607
|
all_keys.each do |key|
|
|
@@ -665,7 +665,7 @@ module Steep
|
|
|
665
665
|
end
|
|
666
666
|
|
|
667
667
|
def required
|
|
668
|
-
array = []
|
|
668
|
+
array = [] #: Array[AST::Types::t]
|
|
669
669
|
|
|
670
670
|
positional_params&.each do |param|
|
|
671
671
|
case param
|
|
@@ -680,7 +680,7 @@ module Steep
|
|
|
680
680
|
end
|
|
681
681
|
|
|
682
682
|
def optional
|
|
683
|
-
array = []
|
|
683
|
+
array = [] #: Array[AST::Types::t]
|
|
684
684
|
|
|
685
685
|
positional_params&.each do |param|
|
|
686
686
|
case param
|
data/lib/steep/project/dsl.rb
CHANGED
|
@@ -66,7 +66,7 @@ module Steep
|
|
|
66
66
|
def typing_options(level = nil, **hash)
|
|
67
67
|
Steep.logger.error "#typing_options is deprecated and has no effect as of version 0.46.0. Update your Steepfile as follows for (almost) equivalent setting:"
|
|
68
68
|
|
|
69
|
-
messages = []
|
|
69
|
+
messages = [] #: Array[String]
|
|
70
70
|
|
|
71
71
|
messages << "# D = Steep::Diagnostic # Define a constant to shorten namespace"
|
|
72
72
|
|
|
@@ -83,7 +83,7 @@ module Steep
|
|
|
83
83
|
Steep.logger.error " #{msg}"
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
config = []
|
|
86
|
+
config = [] #: Array[String]
|
|
87
87
|
|
|
88
88
|
if hash[:allow_missing_definitions]
|
|
89
89
|
config << "hash[D::Ruby::MethodDefinitionMissing] = nil # allow_missing_definitions"
|
|
@@ -122,7 +122,7 @@ module Steep
|
|
|
122
122
|
items = begin
|
|
123
123
|
provider.run(line: job.line, column: job.column)
|
|
124
124
|
rescue Parser::SyntaxError
|
|
125
|
-
[]
|
|
125
|
+
[] #: Array[Services::CompletionProvider::item]
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
completion_items = items.map do |item|
|
|
@@ -157,7 +157,7 @@ module Steep
|
|
|
157
157
|
locator = RBS::Locator.new(buffer: buffer, dirs: dirs, decls: decls)
|
|
158
158
|
|
|
159
159
|
_hd, tail = locator.find2(line: job.line, column: job.column)
|
|
160
|
-
tail ||= []
|
|
160
|
+
tail ||= [] #: Array[RBS::Locator::component]
|
|
161
161
|
|
|
162
162
|
tail.reverse_each do |t|
|
|
163
163
|
case t
|
|
@@ -430,7 +430,7 @@ module Steep
|
|
|
430
430
|
when AST::Types::Name::Singleton
|
|
431
431
|
singleton_super_types(relation.sub_type.name)
|
|
432
432
|
else
|
|
433
|
-
[]
|
|
433
|
+
[] #: Array[super_type]
|
|
434
434
|
end
|
|
435
435
|
|
|
436
436
|
unless possible_sub_types.empty?
|
|
@@ -743,7 +743,7 @@ module Steep
|
|
|
743
743
|
args.each {|arg| constraints.unknown!(arg.name) }
|
|
744
744
|
|
|
745
745
|
upper_bounds = {}
|
|
746
|
-
relations = []
|
|
746
|
+
relations = [] #: Array[Relation]
|
|
747
747
|
|
|
748
748
|
args.zip(sub_type.type_params, super_type.type_params).each do |arg, sub_param, sup_param|
|
|
749
749
|
sub_ub = sub_param.upper_bound
|
|
@@ -1778,7 +1778,10 @@ module Steep
|
|
|
1778
1778
|
yield_self do
|
|
1779
1779
|
left_node, right_node = node.children
|
|
1780
1780
|
|
|
1781
|
-
|
|
1781
|
+
if hint
|
|
1782
|
+
left_hint = union_type_unify(hint, AST::Builtin.nil_type, AST::Builtin.false_type)
|
|
1783
|
+
end
|
|
1784
|
+
left_type, constr, left_context = synthesize(left_node, hint: left_hint, condition: true).to_ary
|
|
1782
1785
|
|
|
1783
1786
|
interpreter = TypeInference::LogicTypeInterpreter.new(subtyping: checker, typing: typing, config: builder_config)
|
|
1784
1787
|
left_truthy, left_falsy = interpreter.eval(env: left_context.type_env, node: left_node)
|
|
@@ -1888,7 +1891,7 @@ module Steep
|
|
|
1888
1891
|
if loc.respond_to?(:keyword)
|
|
1889
1892
|
condition_loc = loc #: NodeHelper::condition_loc
|
|
1890
1893
|
case condition_loc.keyword.source
|
|
1891
|
-
when "if"
|
|
1894
|
+
when "if", "elsif"
|
|
1892
1895
|
location = condition_loc.begin || condition_loc.keyword
|
|
1893
1896
|
when "unless"
|
|
1894
1897
|
# `else` token always exists
|
|
@@ -1913,8 +1916,9 @@ module Steep
|
|
|
1913
1916
|
|
|
1914
1917
|
if loc.respond_to?(:keyword)
|
|
1915
1918
|
condition_loc = loc #: NodeHelper::condition_loc
|
|
1919
|
+
|
|
1916
1920
|
case condition_loc.keyword.source
|
|
1917
|
-
when "if"
|
|
1921
|
+
when "if", "elsif"
|
|
1918
1922
|
# `else` token always exists
|
|
1919
1923
|
location = condition_loc.else || raise
|
|
1920
1924
|
when "unless"
|
|
@@ -292,7 +292,7 @@ module Steep
|
|
|
292
292
|
)
|
|
293
293
|
|
|
294
294
|
truthy_result = Result.new(type: TRUE, env: truthy_env, unreachable: false)
|
|
295
|
-
truthy_result.unreachable! if
|
|
295
|
+
truthy_result.unreachable! if no_subtyping?(sub_type: AST::Builtin.nil_type, super_type: receiver_type)
|
|
296
296
|
|
|
297
297
|
falsy_result = Result.new(type: FALSE, env: falsy_env, unreachable: false)
|
|
298
298
|
falsy_result.unreachable! unless unwrap
|
|
@@ -529,15 +529,14 @@ module Steep
|
|
|
529
529
|
# 3. K <: T (example: T = Numeric, K = Integer)
|
|
530
530
|
# 4. none of the above (example: T = String, K = Integer)
|
|
531
531
|
|
|
532
|
-
|
|
533
|
-
if subtyping.check(relation, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.instance, instance_type: AST::Types::Instance.instance, class_type: AST::Types::Class.instance).success?
|
|
532
|
+
if subtyping?(sub_type: type, super_type: instance_type)
|
|
534
533
|
# 1 or 2. Satisfies the condition, no narrowing because `type` is already more specific than/equals to `instance_type`
|
|
535
534
|
[
|
|
536
535
|
[type],
|
|
537
536
|
[]
|
|
538
537
|
]
|
|
539
538
|
else
|
|
540
|
-
if subtyping
|
|
539
|
+
if subtyping?(sub_type: instance_type, super_type: type)
|
|
541
540
|
# 3. Satisfied the condition, narrows to `instance_type`, but cannot remove it from *falsy* list
|
|
542
541
|
[
|
|
543
542
|
[instance_type],
|
|
@@ -554,6 +553,19 @@ module Steep
|
|
|
554
553
|
end
|
|
555
554
|
end
|
|
556
555
|
|
|
556
|
+
def no_subtyping?(sub_type:, super_type:)
|
|
557
|
+
relation = Subtyping::Relation.new(sub_type: sub_type, super_type: super_type)
|
|
558
|
+
result = subtyping.check(relation, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.instance, instance_type: AST::Types::Instance.instance, class_type: AST::Types::Class.instance)
|
|
559
|
+
|
|
560
|
+
if result.failure?
|
|
561
|
+
result
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
def subtyping?(sub_type:, super_type:)
|
|
566
|
+
!no_subtyping?(sub_type: sub_type, super_type: super_type)
|
|
567
|
+
end
|
|
568
|
+
|
|
557
569
|
def try_convert(type, method)
|
|
558
570
|
if shape = subtyping.builder.shape(type, public_only: true, config: config)
|
|
559
571
|
if entry = shape.methods[method]
|
|
@@ -9,7 +9,7 @@ module Steep
|
|
|
9
9
|
attr_reader :pure_method_calls
|
|
10
10
|
|
|
11
11
|
def to_s
|
|
12
|
-
array = []
|
|
12
|
+
array = [] #: Array[String]
|
|
13
13
|
|
|
14
14
|
local_variable_types.each do |name, entry|
|
|
15
15
|
if enforced_type = entry[1]
|
|
@@ -108,7 +108,7 @@ module Steep
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def assign_local_variables(assignments)
|
|
111
|
-
local_variable_types = {}
|
|
111
|
+
local_variable_types = {} #: Hash[Symbol, local_variable_entry]
|
|
112
112
|
invalidated_nodes = Set[]
|
|
113
113
|
|
|
114
114
|
assignments.each do |name, new_type|
|
|
@@ -135,7 +135,7 @@ module Steep
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
def refine_types(local_variable_types: {}, pure_call_types: {})
|
|
138
|
-
local_variable_updates = {}
|
|
138
|
+
local_variable_updates = {} #: Hash[Symbol, local_variable_entry]
|
|
139
139
|
|
|
140
140
|
local_variable_types.each do |name, type|
|
|
141
141
|
local_variable_name!(name)
|
data/lib/steep/version.rb
CHANGED
data/sample/lib/conference.rb
CHANGED
|
@@ -2,7 +2,7 @@ module Steep
|
|
|
2
2
|
module AST
|
|
3
3
|
module Annotation
|
|
4
4
|
class Collection
|
|
5
|
-
attr_reader annotations:
|
|
5
|
+
attr_reader annotations: Array[Annotation::t]
|
|
6
6
|
|
|
7
7
|
attr_reader factory: Types::Factory
|
|
8
8
|
|
|
@@ -14,31 +14,34 @@ module Steep
|
|
|
14
14
|
|
|
15
15
|
attr_reader ivar_type_annotations: Hash[Symbol, IvarType]
|
|
16
16
|
|
|
17
|
-
attr_reader method_type_annotations:
|
|
17
|
+
attr_reader method_type_annotations: Hash[Symbol, MethodType?]
|
|
18
18
|
|
|
19
|
-
attr_reader block_type_annotation:
|
|
19
|
+
attr_reader block_type_annotation: BlockType?
|
|
20
20
|
|
|
21
|
-
attr_reader return_type_annotation:
|
|
21
|
+
attr_reader return_type_annotation: ReturnType?
|
|
22
22
|
|
|
23
|
-
attr_reader self_type_annotation:
|
|
23
|
+
attr_reader self_type_annotation: SelfType?
|
|
24
24
|
|
|
25
|
-
attr_reader instance_type_annotation:
|
|
25
|
+
attr_reader instance_type_annotation: InstanceType?
|
|
26
26
|
|
|
27
|
-
attr_reader module_type_annotation:
|
|
27
|
+
attr_reader module_type_annotation: ModuleType?
|
|
28
28
|
|
|
29
29
|
attr_reader implement_module_annotation: Implements?
|
|
30
30
|
|
|
31
|
-
attr_reader dynamic_annotations:
|
|
31
|
+
attr_reader dynamic_annotations: Array[Dynamic]
|
|
32
32
|
|
|
33
|
-
attr_reader break_type_annotation:
|
|
33
|
+
attr_reader break_type_annotation: BreakType?
|
|
34
34
|
|
|
35
|
-
def initialize: (annotations:
|
|
35
|
+
def initialize: (annotations: Array[Annotation::t], factory: Types::Factory, context: RBS::Resolver::context) -> void
|
|
36
36
|
|
|
37
|
-
def absolute_type: (
|
|
37
|
+
def absolute_type: (Types::t) -> Types::t
|
|
38
|
+
| (Types::t?) -> Types::t?
|
|
38
39
|
|
|
39
|
-
def var_type: (
|
|
40
|
+
def var_type: (lvar: Symbol) -> Types::t?
|
|
41
|
+
| (ivar: Symbol) -> Types::t?
|
|
42
|
+
| (const: RBS::TypeName) -> Types::t?
|
|
40
43
|
|
|
41
|
-
def method_type: (
|
|
44
|
+
def method_type: (Symbol name) -> Interface::MethodType?
|
|
42
45
|
|
|
43
46
|
%a{pure} def block_type: () -> Types::t?
|
|
44
47
|
|
|
@@ -52,23 +55,23 @@ module Steep
|
|
|
52
55
|
|
|
53
56
|
%a{pure} def break_type: () -> Types::t?
|
|
54
57
|
|
|
55
|
-
def lvar_types: () ->
|
|
58
|
+
def lvar_types: () -> Hash[Symbol, Types::t]
|
|
56
59
|
|
|
57
|
-
def ivar_types: () ->
|
|
60
|
+
def ivar_types: () -> Hash[Symbol, Types::t]
|
|
58
61
|
|
|
59
|
-
def const_types: () ->
|
|
62
|
+
def const_types: () -> Hash[RBS::TypeName, Types::t]
|
|
60
63
|
|
|
61
|
-
def instance_dynamics: () ->
|
|
64
|
+
def instance_dynamics: () -> Array[Symbol]
|
|
62
65
|
|
|
63
|
-
def module_dynamics: () ->
|
|
66
|
+
def module_dynamics: () -> Array[Symbol]
|
|
64
67
|
|
|
65
|
-
def merge_block_annotations: (
|
|
68
|
+
def merge_block_annotations: (Collection annotations) -> Collection
|
|
66
69
|
|
|
67
|
-
def any?: () { () ->
|
|
70
|
+
def any?: () { (Annotation::t) -> boolish } -> bool
|
|
68
71
|
|
|
69
|
-
def size: () ->
|
|
72
|
+
def size: () -> Integer
|
|
70
73
|
|
|
71
|
-
def include?: (
|
|
74
|
+
def include?: (Annotation::t obj) -> bool
|
|
72
75
|
end
|
|
73
76
|
end
|
|
74
77
|
end
|
|
@@ -546,11 +546,9 @@ module Steep
|
|
|
546
546
|
end
|
|
547
547
|
|
|
548
548
|
class UnexpectedError < Base
|
|
549
|
-
attr_reader
|
|
550
|
-
|
|
551
|
-
attr_reader error: untyped
|
|
549
|
+
attr_reader error: Exception
|
|
552
550
|
|
|
553
|
-
def initialize: (node:
|
|
551
|
+
def initialize: (node: Parser::AST::Node, error: Exception) -> void
|
|
554
552
|
|
|
555
553
|
def header_line: () -> ::String
|
|
556
554
|
end
|
|
@@ -71,6 +71,18 @@ module Steep
|
|
|
71
71
|
|
|
72
72
|
# Substitution for immediate type expressions
|
|
73
73
|
def subst: () -> Substitution
|
|
74
|
+
|
|
75
|
+
# Returns `self_type`, or `nil` when it is `Types::Self`
|
|
76
|
+
#
|
|
77
|
+
def self_type?: () -> AST::Types::t?
|
|
78
|
+
|
|
79
|
+
# Returns `class_type`, or `nil` when it is `Types::Class`
|
|
80
|
+
#
|
|
81
|
+
def class_type?: () -> AST::Types::t?
|
|
82
|
+
|
|
83
|
+
# Returns `instanc_type`, or `nil` when it is `Types::Instance`
|
|
84
|
+
#
|
|
85
|
+
def instance_type?: () -> AST::Types::t?
|
|
74
86
|
end
|
|
75
87
|
|
|
76
88
|
attr_reader factory: AST::Types::Factory
|
|
@@ -99,6 +99,10 @@ module Steep
|
|
|
99
99
|
def type_case_select0: (AST::Types::t `type`, RBS::TypeName klass) -> [Array[AST::Types::t], Array[AST::Types::t]]
|
|
100
100
|
|
|
101
101
|
def try_convert: (AST::Types::t, Symbol) -> AST::Types::t?
|
|
102
|
+
|
|
103
|
+
def no_subtyping?: (sub_type: AST::Types::t, super_type: AST::Types::t) -> Subtyping::Result::t?
|
|
104
|
+
|
|
105
|
+
def subtyping?: (sub_type: AST::Types::t, super_type: AST::Types::t) -> bool
|
|
102
106
|
end
|
|
103
107
|
end
|
|
104
108
|
end
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
---
|
|
2
|
-
- file: unexpected.rb
|
|
3
|
-
diagnostics:
|
|
4
|
-
- range:
|
|
5
|
-
start:
|
|
6
|
-
line: 1
|
|
7
|
-
character: 0
|
|
8
|
-
end:
|
|
9
|
-
line: 1
|
|
10
|
-
character: 14
|
|
11
|
-
severity: ERROR
|
|
12
|
-
message: 'UnexpectedError: unexpected.rbs:2:17...2:24: Could not find String1'
|
|
13
|
-
code: Ruby::UnexpectedError
|
|
14
2
|
- file: unexpected.rbs
|
|
15
3
|
diagnostics:
|
|
16
4
|
- range:
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: steep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Soutaro Matsumoto
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-07-
|
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: parser
|
|
@@ -242,7 +242,6 @@ files:
|
|
|
242
242
|
- Gemfile
|
|
243
243
|
- Gemfile.lock
|
|
244
244
|
- Gemfile.steep
|
|
245
|
-
- Gemfile.steep.lock
|
|
246
245
|
- LICENSE
|
|
247
246
|
- README.md
|
|
248
247
|
- Rakefile
|
|
@@ -255,6 +254,8 @@ files:
|
|
|
255
254
|
- bin/steep
|
|
256
255
|
- bin/steep-prof
|
|
257
256
|
- exe/steep
|
|
257
|
+
- gemfile_steep/Gemfile
|
|
258
|
+
- gemfile_steep/Gemfile.lock
|
|
258
259
|
- guides/README.md
|
|
259
260
|
- guides/src/gem-rbs-collection/gem-rbs-collection.md
|
|
260
261
|
- guides/src/getting-started/getting-started.md
|
|
@@ -266,7 +267,6 @@ files:
|
|
|
266
267
|
- lib/steep/ast/builtin.rb
|
|
267
268
|
- lib/steep/ast/node/type_application.rb
|
|
268
269
|
- lib/steep/ast/node/type_assertion.rb
|
|
269
|
-
- lib/steep/ast/type_params.rb
|
|
270
270
|
- lib/steep/ast/types/any.rb
|
|
271
271
|
- lib/steep/ast/types/boolean.rb
|
|
272
272
|
- lib/steep/ast/types/bot.rb
|
|
@@ -401,7 +401,6 @@ files:
|
|
|
401
401
|
- sig/steep/ast/builtin.rbs
|
|
402
402
|
- sig/steep/ast/node/type_application.rbs
|
|
403
403
|
- sig/steep/ast/node/type_assertion.rbs
|
|
404
|
-
- sig/steep/ast/type_params.rbs
|
|
405
404
|
- sig/steep/ast/types.rbs
|
|
406
405
|
- sig/steep/ast/types/any.rbs
|
|
407
406
|
- sig/steep/ast/types/boolean.rbs
|
|
@@ -757,7 +756,6 @@ files:
|
|
|
757
756
|
- smoke/type_case/test_expectations.yml
|
|
758
757
|
- smoke/unexpected/Steepfile
|
|
759
758
|
- smoke/unexpected/test_expectations.yml
|
|
760
|
-
- smoke/unexpected/unexpected.rb
|
|
761
759
|
- smoke/unexpected/unexpected.rbs
|
|
762
760
|
- smoke/yield/Steepfile
|
|
763
761
|
- smoke/yield/a.rb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Unexpected.new.foo().bar
|