steep 0.21.0 → 0.22.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 +7 -0
- data/Gemfile +7 -0
- data/bin/steep-prof +16 -0
- data/lib/steep/ast/types/literal.rb +4 -0
- data/lib/steep/project/target.rb +12 -1
- 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/subtyping/check.rb +17 -0
- data/lib/steep/type_construction.rb +7 -1
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +1 -8
- metadata +5 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1008a3723d59bab0d00afb4b385ee2752d8679461416eba84e48cc9ae479b0a4
|
4
|
+
data.tar.gz: 58c470fe9d8c619d9d0767a392ab6557b6dc50b007c6c99ff6ad27a79a88ecd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f1074ca3634f9df53f361f78a4838912cb7420918f72afdb08e49ab9d64bbe97177780a54648526ff3947b36ab2f0fb2fec3fce73ed97ce0b835359c81ff52d
|
7
|
+
data.tar.gz: b1c5b3fb447832fb648a56b4d827592ba0ddd719e384795786e27201a32305ce36a0d93edde61c94a311708599dd7090359bc1f15ae04ef0fa3717bd897cb580
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.22.0 (2020-08-03)
|
6
|
+
|
7
|
+
* Improve signature validation ([#175](https://github.com/soutaro/steep/pull/175), [#177](https://github.com/soutaro/steep/pull/177))
|
8
|
+
* Fix boolean literal typing ([#172](https://github.com/soutaro/steep/pull/172))
|
9
|
+
* Make exit code success when Steep has unreported type errors ([#171](https://github.com/soutaro/steep/pull/171))
|
10
|
+
* Allow `./` prefix for signature pattern ([#170](https://github.com/soutaro/steep/pull/170))
|
11
|
+
|
5
12
|
## 0.21.0 (2020-07-20)
|
6
13
|
|
7
14
|
* Fix LSP hover ([#168](https://github.com/soutaro/steep/pull/168))
|
data/Gemfile
CHANGED
@@ -5,3 +5,10 @@ gemspec
|
|
5
5
|
|
6
6
|
gem "with_steep_types", path: "test/gems/with_steep_types"
|
7
7
|
gem "without_steep_types", path: "test/gems/without_steep_types"
|
8
|
+
|
9
|
+
gem "rake"
|
10
|
+
gem "minitest", "~> 5.0"
|
11
|
+
gem "racc", "~> 1.4"
|
12
|
+
gem "minitest-reporters"
|
13
|
+
gem "minitest-hooks"
|
14
|
+
gem "stackprof"
|
data/bin/steep-prof
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "stackprof"
|
4
|
+
|
5
|
+
mode = (ENV["STEEP_STACKPROF_MODE"] || :wall).to_sym
|
6
|
+
out = ENV["STEEP_STACKPROF_OUT"] || "tmp/stackprof-#{mode}-steep.dump"
|
7
|
+
|
8
|
+
def exit(*)
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
STDERR.puts "Running profiler: mode=#{mode}, out=#{out}"
|
14
|
+
StackProf.run(mode: mode, out: out) do
|
15
|
+
load File.join(__dir__, "../exe/steep")
|
16
|
+
end
|
data/lib/steep/project/target.rb
CHANGED
@@ -79,6 +79,7 @@ module Steep
|
|
79
79
|
def self.test_pattern(patterns, path, ext:)
|
80
80
|
patterns.any? do |pattern|
|
81
81
|
p = pattern.end_with?(File::Separator) ? pattern : pattern + File::Separator
|
82
|
+
p.delete_prefix!('./')
|
82
83
|
(path.to_s.start_with?(p) && path.extname == ext) || File.fnmatch(pattern, path.to_s)
|
83
84
|
end
|
84
85
|
end
|
@@ -160,6 +161,16 @@ module Steep
|
|
160
161
|
else
|
161
162
|
yield env, check, Time.now
|
162
163
|
end
|
164
|
+
rescue RBS::DuplicatedDeclarationError => exn
|
165
|
+
@status = SignatureValidationErrorStatus.new(
|
166
|
+
errors: [
|
167
|
+
Signature::Errors::DuplicatedDefinitionError.new(
|
168
|
+
name: exn.name,
|
169
|
+
location: exn.decls[0].location
|
170
|
+
)
|
171
|
+
],
|
172
|
+
timestamp: Time.now
|
173
|
+
)
|
163
174
|
rescue => exn
|
164
175
|
@status = SignatureOtherErrorStatus.new(error: exn, timestamp: Time.now)
|
165
176
|
end
|
@@ -205,7 +216,7 @@ module Steep
|
|
205
216
|
def errors
|
206
217
|
case status
|
207
218
|
when TypeCheckStatus
|
208
|
-
source_files.each_value.flat_map(&:errors)
|
219
|
+
source_files.each_value.flat_map(&:errors).select { |error | options.error_to_report?(error) }
|
209
220
|
else
|
210
221
|
[]
|
211
222
|
end
|
@@ -112,6 +112,9 @@ module Steep
|
|
112
112
|
target.signature_files.each_key.with_object({}) do |path, hash|
|
113
113
|
hash[path] = []
|
114
114
|
end
|
115
|
+
when Project::Target::SignatureOtherErrorStatus
|
116
|
+
Steep.log_error status.error
|
117
|
+
{}
|
115
118
|
else
|
116
119
|
Steep.logger.info "Unexpected target status: #{status.class}"
|
117
120
|
{}
|
@@ -19,6 +19,19 @@ module Steep
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
class DuplicatedDefinitionError < Base
|
23
|
+
attr_reader :name
|
24
|
+
|
25
|
+
def initialize(name:, location:)
|
26
|
+
@name = name
|
27
|
+
@location = location
|
28
|
+
end
|
29
|
+
|
30
|
+
def puts(io)
|
31
|
+
io.puts "#{loc_to_s}\sDuplicatedDefinitionError: name=#{name}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
class UnknownTypeNameError < Base
|
23
36
|
attr_reader :name
|
24
37
|
|
@@ -48,6 +61,21 @@ module Steep
|
|
48
61
|
io.puts "#{loc_to_s}\tInvalidTypeApplicationError: name=#{name}, expected=[#{params.join(", ")}], actual=[#{args.join(", ")}]"
|
49
62
|
end
|
50
63
|
end
|
64
|
+
|
65
|
+
class InvalidMethodOverloadError < Base
|
66
|
+
attr_reader :class_name
|
67
|
+
attr_reader :method_name
|
68
|
+
|
69
|
+
def initialize(class_name:, method_name:, location:)
|
70
|
+
@class_name = class_name
|
71
|
+
@method_name = method_name
|
72
|
+
@location = location
|
73
|
+
end
|
74
|
+
|
75
|
+
def puts(io)
|
76
|
+
io.puts "#{loc_to_s}\tInvalidMethodOverloadError: class_name=#{class_name}, method_name=#{method_name}"
|
77
|
+
end
|
78
|
+
end
|
51
79
|
end
|
52
80
|
end
|
53
81
|
end
|
@@ -53,6 +53,7 @@ module Steep
|
|
53
53
|
validate_decl
|
54
54
|
validate_const
|
55
55
|
validate_global
|
56
|
+
validate_alias
|
56
57
|
end
|
57
58
|
|
58
59
|
def validate_type(type)
|
@@ -99,6 +100,7 @@ module Steep
|
|
99
100
|
env.constant_decls.each do |name, entry|
|
100
101
|
rescue_validation_errors do
|
101
102
|
Steep.logger.debug "Validating constant `#{name}`..."
|
103
|
+
builder.ensure_namespace!(name.namespace, location: entry.decl.location)
|
102
104
|
validate_type entry.decl.type
|
103
105
|
end
|
104
106
|
end
|
@@ -117,7 +119,9 @@ module Steep
|
|
117
119
|
env.alias_decls.each do |name, entry|
|
118
120
|
rescue_validation_errors do
|
119
121
|
Steep.logger.debug "Validating alias `#{name}`..."
|
120
|
-
|
122
|
+
builder.expand_alias(name).tap do |type|
|
123
|
+
validate_type(type)
|
124
|
+
end
|
121
125
|
end
|
122
126
|
end
|
123
127
|
end
|
@@ -136,6 +140,12 @@ module Steep
|
|
136
140
|
name: factory.type_name(exn.type_name),
|
137
141
|
location: exn.location
|
138
142
|
)
|
143
|
+
rescue RBS::InvalidOverloadMethodError => exn
|
144
|
+
@errors << Errors::InvalidMethodOverloadError.new(
|
145
|
+
class_name: factory.type_name(exn.type_name),
|
146
|
+
method_name: exn.method_name,
|
147
|
+
location: exn.members[0].location
|
148
|
+
)
|
139
149
|
end
|
140
150
|
end
|
141
151
|
end
|
@@ -369,6 +369,23 @@ module Steep
|
|
369
369
|
trace: trace,
|
370
370
|
constraints: constraints)
|
371
371
|
|
372
|
+
when relation.super_type.is_a?(AST::Types::Literal)
|
373
|
+
case
|
374
|
+
when relation.super_type.value == true && AST::Builtin::TrueClass.instance_type?(relation.sub_type)
|
375
|
+
success(constraints: constraints)
|
376
|
+
when relation.super_type.value == false && AST::Builtin::FalseClass.instance_type?(relation.sub_type)
|
377
|
+
success(constraints: constraints)
|
378
|
+
else
|
379
|
+
failure(error: Result::Failure::UnknownPairError.new(relation: relation),
|
380
|
+
trace: trace)
|
381
|
+
end
|
382
|
+
|
383
|
+
when relation.super_type.is_a?(AST::Types::Nil) && AST::Builtin::NilClass.instance_type?(relation.sub_type)
|
384
|
+
success(constraints: constraints)
|
385
|
+
|
386
|
+
when relation.sub_type.is_a?(AST::Types::Nil) && AST::Builtin::NilClass.instance_type?(relation.super_type)
|
387
|
+
success(constraints: constraints)
|
388
|
+
|
372
389
|
else
|
373
390
|
failure(error: Result::Failure::UnknownPairError.new(relation: relation),
|
374
391
|
trace: trace)
|
@@ -1094,7 +1094,13 @@ module Steep
|
|
1094
1094
|
end
|
1095
1095
|
|
1096
1096
|
when :true, :false
|
1097
|
-
|
1097
|
+
ty = node.type == :true ? AST::Types::Literal.new(value: true) : AST::Types::Literal.new(value: false)
|
1098
|
+
|
1099
|
+
if hint && check_relation(sub_type: ty, super_type: hint).success?
|
1100
|
+
add_typing(node, type: hint)
|
1101
|
+
else
|
1102
|
+
add_typing(node, type: AST::Types::Boolean.new)
|
1103
|
+
end
|
1098
1104
|
|
1099
1105
|
when :hash
|
1100
1106
|
yield_self do
|
data/lib/steep/version.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", "~> 0.
|
37
|
+
spec.add_runtime_dependency "rbs", "~> 0.9.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.22.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-02 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
|
@@ -190,14 +106,14 @@ dependencies:
|
|
190
106
|
requirements:
|
191
107
|
- - "~>"
|
192
108
|
- !ruby/object:Gem::Version
|
193
|
-
version: 0.
|
109
|
+
version: 0.9.0
|
194
110
|
type: :runtime
|
195
111
|
prerelease: false
|
196
112
|
version_requirements: !ruby/object:Gem::Requirement
|
197
113
|
requirements:
|
198
114
|
- - "~>"
|
199
115
|
- !ruby/object:Gem::Version
|
200
|
-
version: 0.
|
116
|
+
version: 0.9.0
|
201
117
|
description: Gradual Typing for Ruby
|
202
118
|
email:
|
203
119
|
- matsumoto@soutaro.com
|
@@ -218,6 +134,7 @@ files:
|
|
218
134
|
- bin/console
|
219
135
|
- bin/setup
|
220
136
|
- bin/smoke_runner.rb
|
137
|
+
- bin/steep-prof
|
221
138
|
- exe/steep
|
222
139
|
- lib/steep.rb
|
223
140
|
- lib/steep/annotation_parser.rb
|