steep 0.20.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/Gemfile +7 -0
- data/bin/steep-prof +16 -0
- data/lib/steep/ast/types/factory.rb +1 -1
- data/lib/steep/ast/types/literal.rb +4 -0
- data/lib/steep/ast/types/union.rb +4 -1
- data/lib/steep/drivers/check.rb +4 -0
- data/lib/steep/project/target.rb +17 -3
- data/lib/steep/server/interaction_worker.rb +3 -3
- data/lib/steep/server/signature_worker.rb +3 -0
- data/lib/steep/signature/errors.rb +28 -0
- data/lib/steep/signature/validator.rb +11 -1
- data/lib/steep/source.rb +2 -1
- data/lib/steep/subtyping/check.rb +224 -52
- data/lib/steep/type_construction.rb +425 -181
- data/lib/steep/type_inference/constant_env.rb +1 -1
- data/lib/steep/type_inference/context.rb +8 -0
- data/lib/steep/type_inference/context_array.rb +4 -3
- data/lib/steep/type_inference/logic.rb +31 -0
- data/lib/steep/typing.rb +7 -0
- data/lib/steep/version.rb +1 -1
- data/smoke/class/a.rbs +1 -2
- data/smoke/class/f.rb +3 -1
- data/steep.gemspec +1 -8
- metadata +7 -96
@@ -26,7 +26,7 @@ module Steep
|
|
26
26
|
factory.type(constant.type)
|
27
27
|
end
|
28
28
|
rescue => exn
|
29
|
-
Steep.logger.
|
29
|
+
Steep.logger.debug "Looking up a constant failed: name=#{name}, context=[#{context.join(", ")}], error=#{exn.inspect}"
|
30
30
|
nil
|
31
31
|
end
|
32
32
|
end
|
@@ -70,6 +70,14 @@ module Steep
|
|
70
70
|
def const_context
|
71
71
|
const_env.context
|
72
72
|
end
|
73
|
+
|
74
|
+
def class_variables
|
75
|
+
if module_definition
|
76
|
+
@class_variables ||= module_definition.class_variables.transform_values do |var_def|
|
77
|
+
var_def.type
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
73
81
|
end
|
74
82
|
|
75
83
|
attr_reader :method_context
|
@@ -35,12 +35,13 @@ module Steep
|
|
35
35
|
|
36
36
|
def insert_context(range, context:, entry: self.root)
|
37
37
|
entry.sub_entries.each do |sub|
|
38
|
-
next if sub.range.begin
|
39
|
-
next if range.begin
|
38
|
+
next if sub.range.begin <= range.begin && range.end <= sub.range.end
|
39
|
+
next if range.begin <= sub.range.begin && sub.range.end <= range.end
|
40
40
|
next if range.end <= sub.range.begin
|
41
41
|
next if sub.range.end <= range.begin
|
42
42
|
|
43
|
-
|
43
|
+
Steep.logger.error { "Range crossing: sub range=#{sub.range}, new range=#{range}" }
|
44
|
+
raise
|
44
45
|
end
|
45
46
|
|
46
47
|
sup = entry.sub_entries.find do |sub|
|
@@ -47,6 +47,37 @@ module Steep
|
|
47
47
|
f.merge([node])
|
48
48
|
]
|
49
49
|
|
50
|
+
when :masgn
|
51
|
+
lhs, rhs = node.children
|
52
|
+
|
53
|
+
lt, lf = nodes(node: lhs)
|
54
|
+
rt, rf = nodes(node: rhs)
|
55
|
+
|
56
|
+
[
|
57
|
+
(lt + rt).merge([node]),
|
58
|
+
(lf + rf).merge([node])
|
59
|
+
]
|
60
|
+
|
61
|
+
when :mlhs
|
62
|
+
nodes = [node]
|
63
|
+
|
64
|
+
node.children.each do |child|
|
65
|
+
case child.type
|
66
|
+
when :lvasgn
|
67
|
+
nodes << child
|
68
|
+
when :splat
|
69
|
+
if node.children[0].type == :lvasgn
|
70
|
+
nodes << child
|
71
|
+
nodes << child.children[0]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
[
|
77
|
+
Result.new(nodes),
|
78
|
+
Result.new(nodes)
|
79
|
+
]
|
80
|
+
|
50
81
|
when :and
|
51
82
|
lhs, rhs = node.children
|
52
83
|
|
data/lib/steep/typing.rb
CHANGED
@@ -126,6 +126,13 @@ module Steep
|
|
126
126
|
end_pos = node.loc.end.begin_pos
|
127
127
|
add_context(begin_pos..end_pos, context: context)
|
128
128
|
|
129
|
+
when :for
|
130
|
+
_, collection, _ = node.children
|
131
|
+
|
132
|
+
begin_pos = collection.loc.expression.end_pos
|
133
|
+
end_pos = node.loc.end.begin_pos
|
134
|
+
|
135
|
+
add_context(begin_pos..end_pos, context: context)
|
129
136
|
else
|
130
137
|
raise "Unexpected node for insert_context: #{node.type}"
|
131
138
|
end
|
data/lib/steep/version.rb
CHANGED
data/smoke/class/a.rbs
CHANGED
data/smoke/class/f.rb
CHANGED
data/steep.gemspec
CHANGED
@@ -28,18 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.required_ruby_version = '>= 2.6.0'
|
30
30
|
|
31
|
-
spec.add_development_dependency "bundler", ">= 1.13"
|
32
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
33
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
-
spec.add_development_dependency "racc", "~> 1.4"
|
35
|
-
spec.add_development_dependency "minitest-reporters", "~> 1.4.2"
|
36
|
-
spec.add_development_dependency "minitest-hooks", "~> 1.5.0"
|
37
|
-
|
38
31
|
spec.add_runtime_dependency "parser", "~> 2.7.0"
|
39
32
|
spec.add_runtime_dependency "ast_utils", "~> 0.3.0"
|
40
33
|
spec.add_runtime_dependency "activesupport", ">= 5.1"
|
41
34
|
spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
|
42
35
|
spec.add_runtime_dependency "listen", "~> 3.1"
|
43
36
|
spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0.2"
|
44
|
-
spec.add_runtime_dependency "rbs", "
|
37
|
+
spec.add_runtime_dependency "rbs", "~> 0.10.0"
|
45
38
|
end
|
metadata
CHANGED
@@ -1,99 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.13'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.13'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '13.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '13.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: racc
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.4'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.4'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest-reporters
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.4.2
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.4.2
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest-hooks
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.5.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.5.0
|
97
13
|
- !ruby/object:Gem::Dependency
|
98
14
|
name: parser
|
99
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,22 +104,16 @@ dependencies:
|
|
188
104
|
name: rbs
|
189
105
|
requirement: !ruby/object:Gem::Requirement
|
190
106
|
requirements:
|
191
|
-
- - "
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: 0.6.0
|
194
|
-
- - "<"
|
107
|
+
- - "~>"
|
195
108
|
- !ruby/object:Gem::Version
|
196
|
-
version: 0.
|
109
|
+
version: 0.10.0
|
197
110
|
type: :runtime
|
198
111
|
prerelease: false
|
199
112
|
version_requirements: !ruby/object:Gem::Requirement
|
200
113
|
requirements:
|
201
|
-
- - "
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
version: 0.6.0
|
204
|
-
- - "<"
|
114
|
+
- - "~>"
|
205
115
|
- !ruby/object:Gem::Version
|
206
|
-
version: 0.
|
116
|
+
version: 0.10.0
|
207
117
|
description: Gradual Typing for Ruby
|
208
118
|
email:
|
209
119
|
- matsumoto@soutaro.com
|
@@ -224,6 +134,7 @@ files:
|
|
224
134
|
- bin/console
|
225
135
|
- bin/setup
|
226
136
|
- bin/smoke_runner.rb
|
137
|
+
- bin/steep-prof
|
227
138
|
- exe/steep
|
228
139
|
- lib/steep.rb
|
229
140
|
- lib/steep/annotation_parser.rb
|