steep 1.5.1 → 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 +11 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/Gemfile.steep +0 -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} +2 -1
- data/lib/steep/interface/builder.rb +28 -8
- data/lib/steep/services/completion_provider.rb +3 -0
- data/lib/steep/type_inference/logic_type_interpreter.rb +16 -4
- data/lib/steep/version.rb +1 -1
- data/rbs_collection.steep.lock.yaml +1 -1
- data/sig/steep/interface/builder.rbs +12 -0
- data/sig/steep/type_inference/logic_type_interpreter.rbs +4 -0
- metadata +4 -3
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,17 @@
|
|
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
|
+
|
5
16
|
## 1.5.1 (2023-07-20)
|
6
17
|
|
7
18
|
### 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)
|
@@ -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/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"
|
@@ -30,7 +30,7 @@ GEM
|
|
30
30
|
ffi (~> 1.0)
|
31
31
|
rbs (3.1.1)
|
32
32
|
securerandom (0.2.2)
|
33
|
-
steep (1.5.
|
33
|
+
steep (1.5.1)
|
34
34
|
activesupport (>= 5.1)
|
35
35
|
concurrent-ruby (>= 1.1.10)
|
36
36
|
csv (>= 3.0.9)
|
@@ -55,6 +55,7 @@ GEM
|
|
55
55
|
PLATFORMS
|
56
56
|
arm64-darwin-21
|
57
57
|
arm64-darwin-22
|
58
|
+
x86_64-linux
|
58
59
|
|
59
60
|
DEPENDENCIES
|
60
61
|
steep
|
@@ -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
|
|
@@ -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]
|
data/lib/steep/version.rb
CHANGED
@@ -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
|
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
|