steep 1.4.0.dev.5 → 1.4.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 +35 -0
- data/Gemfile.lock +2 -2
- data/Gemfile.steep.lock +2 -3
- data/lib/steep/diagnostic/lsp_formatter.rb +1 -1
- data/lib/steep/diagnostic/ruby.rb +5 -4
- data/lib/steep/server/interaction_worker.rb +3 -2
- data/lib/steep/subtyping/check.rb +13 -16
- data/lib/steep/type_construction.rb +37 -23
- data/lib/steep/version.rb +1 -1
- data/sig/steep/subtyping/check.rbs +1 -1
- data/sig/steep/type_construction.rbs +2 -0
- data/smoke/regression/Steepfile +0 -1
- data/smoke/regression/enumerator_product.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0c3f3309cc8169ca1616f43b6bfcaf977339107d6e6e14f7c256d71921b9455
|
4
|
+
data.tar.gz: 0a85c1429383a0321fe2932befbd880942c00df1e788913a4f5c2e3d8abd9479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce071dd59d2a6e4c21c9c2114d33603e4628052074b7a6f8500f8e4380ca53dfdd77baac210c1ced711eeccc7da94257baceefdafe5633cbd3932687dab6e8c
|
7
|
+
data.tar.gz: db71a9ab6ca415b266e62b7ef17a34e88dd4135326bae512fcf8fe8051610a6c2259bcf11773f09ebb8192958d96f03154a5a1be955beddc7088f2bfc0bf57a5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,41 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.4.0 (2023-04-25)
|
6
|
+
|
7
|
+
### Type checker core
|
8
|
+
|
9
|
+
* Return immediately if blocks are incompatible ([#765](https://github.com/soutaro/steep/pull/765))
|
10
|
+
* Fix location of no method error ([#763](https://github.com/soutaro/steep/pull/763))
|
11
|
+
* Support `gvasgn` in assignment variants ([#762](https://github.com/soutaro/steep/pull/762))
|
12
|
+
* Set up break contexts correctly for untyped blocks ([#752](https://github.com/soutaro/steep/pull/752))
|
13
|
+
* Fix flow sensitive on `case` without condition ([#751](https://github.com/soutaro/steep/pull/751))
|
14
|
+
* Support `...` syntax ([#750](https://github.com/soutaro/steep/pull/750))
|
15
|
+
* Fix constant declaration type checking ([#738](https://github.com/soutaro/steep/pull/738))
|
16
|
+
* Fix errors caused by non-ascii variable names ([#703](https://github.com/soutaro/steep/pull/703))
|
17
|
+
* Update RBS to 3.0 ([#716](https://github.com/soutaro/steep/pull/716), [#754](https://github.com/soutaro/steep/pull/754))
|
18
|
+
|
19
|
+
### Language server
|
20
|
+
|
21
|
+
* Implement signature help, better completion and hover ([#759](https://github.com/soutaro/steep/pull/759), [#761](https://github.com/soutaro/steep/pull/761), [#766](https://github.com/soutaro/steep/pull/766))
|
22
|
+
|
23
|
+
### Miscellaneous
|
24
|
+
|
25
|
+
* Remove pathname from runtime_dependency ([#739](https://github.com/soutaro/steep/pull/739))
|
26
|
+
* `parallel` out, `concurrent-ruby` in ([#760](https://github.com/soutaro/steep/pull/760))
|
27
|
+
|
28
|
+
## 1.3.2 (2023-03-17)
|
29
|
+
|
30
|
+
### Miscellaneous
|
31
|
+
|
32
|
+
* Remove pathname from runtime_dependency ([#740](https://github.com/soutaro/steep/pull/740))
|
33
|
+
|
34
|
+
## 1.3.1 (2023-03-08)
|
35
|
+
|
36
|
+
### Miscellaneous
|
37
|
+
|
38
|
+
* Require rbs-2.8.x ([#732](https://github.com/soutaro/steep/pull/732))
|
39
|
+
|
5
40
|
## 1.3.0 (2022-11-25)
|
6
41
|
|
7
42
|
### Type checker core
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steep (1.4.0
|
4
|
+
steep (1.4.0)
|
5
5
|
activesupport (>= 5.1)
|
6
6
|
concurrent-ruby (>= 1.2.2)
|
7
7
|
csv (>= 3.0.9)
|
@@ -46,7 +46,7 @@ GEM
|
|
46
46
|
minitest (> 5.3)
|
47
47
|
minitest-slow_test (0.2.0)
|
48
48
|
minitest (>= 5.0)
|
49
|
-
parser (3.2.2.
|
49
|
+
parser (3.2.2.1)
|
50
50
|
ast (~> 2.4.1)
|
51
51
|
rainbow (3.1.1)
|
52
52
|
rake (13.0.6)
|
data/Gemfile.steep.lock
CHANGED
@@ -20,7 +20,6 @@ GEM
|
|
20
20
|
rb-inotify (~> 0.9, >= 0.9.10)
|
21
21
|
logger (1.5.3)
|
22
22
|
minitest (5.18.0)
|
23
|
-
parallel (1.22.1)
|
24
23
|
parser (3.2.2.0)
|
25
24
|
ast (~> 2.4.1)
|
26
25
|
rainbow (3.1.1)
|
@@ -29,15 +28,15 @@ GEM
|
|
29
28
|
ffi (~> 1.0)
|
30
29
|
rbs (3.0.4)
|
31
30
|
securerandom (0.2.2)
|
32
|
-
steep (1.4.0.dev.
|
31
|
+
steep (1.4.0.dev.5)
|
33
32
|
activesupport (>= 5.1)
|
33
|
+
concurrent-ruby (>= 1.2.2)
|
34
34
|
csv (>= 3.0.9)
|
35
35
|
fileutils (>= 1.1.0)
|
36
36
|
json (>= 2.1.0)
|
37
37
|
language_server-protocol (>= 3.15, < 4.0)
|
38
38
|
listen (~> 3.0)
|
39
39
|
logger (>= 1.3.0)
|
40
|
-
parallel (>= 1.0.0)
|
41
40
|
parser (>= 3.1)
|
42
41
|
rainbow (>= 2.2.2, < 4.0)
|
43
42
|
rbs (>= 2.8.0)
|
@@ -41,7 +41,7 @@ module Steep
|
|
41
41
|
severity = severity_for(diagnostic)
|
42
42
|
|
43
43
|
if severity
|
44
|
-
range = diagnostic.location&.as_lsp_range or raise
|
44
|
+
range = diagnostic.location&.as_lsp_range or raise "#{diagnostic.class} object (#{diagnostic.full_message}) instance must have `#location`"
|
45
45
|
|
46
46
|
LSP::Interface::Diagnostic.new(
|
47
47
|
message: diagnostic.full_message,
|
@@ -286,13 +286,14 @@ module Steep
|
|
286
286
|
def initialize(node:, type:, method:)
|
287
287
|
loc = case node.type
|
288
288
|
when :send
|
289
|
-
|
289
|
+
loc = _ = nil
|
290
|
+
loc ||= node.loc.operator if node.loc.respond_to?(:operator)
|
291
|
+
loc ||= node.loc.selector if node.loc.respond_to?(:selector)
|
292
|
+
loc
|
290
293
|
when :block
|
291
294
|
node.children[0].loc.selector
|
292
|
-
else
|
293
|
-
node.loc.expression
|
294
295
|
end
|
295
|
-
super(node: node, location: loc)
|
296
|
+
super(node: node, location: loc || node.loc.expression)
|
296
297
|
@type = type
|
297
298
|
@method = method
|
298
299
|
end
|
@@ -144,7 +144,6 @@ module Steep
|
|
144
144
|
|
145
145
|
case sig_service.status
|
146
146
|
when Services::SignatureService::SyntaxErrorStatus, Services::SignatureService::AncestorErrorStatus
|
147
|
-
|
148
147
|
if buffer = sig_service.latest_env.buffers.find {|buf| Pathname(buf.name) == Pathname(relative_path) }
|
149
148
|
dirs = sig_service.latest_env.signatures[buffer][0]
|
150
149
|
else
|
@@ -208,7 +207,7 @@ module Steep
|
|
208
207
|
end
|
209
208
|
|
210
209
|
LSP::Interface::CompletionList.new(
|
211
|
-
is_incomplete:
|
210
|
+
is_incomplete: !sig_service.status.is_a?(Services::SignatureService::LoadedStatus),
|
212
211
|
items: completion_items
|
213
212
|
)
|
214
213
|
end
|
@@ -394,6 +393,8 @@ module Steep
|
|
394
393
|
end
|
395
394
|
end
|
396
395
|
end
|
396
|
+
rescue Parser::SyntaxError
|
397
|
+
# Ignore syntax error
|
397
398
|
end
|
398
399
|
end
|
399
400
|
end
|
@@ -627,7 +627,7 @@ module Steep
|
|
627
627
|
|
628
628
|
sub_interface, super_interface = relation
|
629
629
|
|
630
|
-
method_pairs = super_interface.methods.each_with_object({}) do |(method_name, sup_method), hash|
|
630
|
+
method_pairs = super_interface.methods.each_with_object({}) do |(method_name, sup_method), hash| #$ Hash[Symbol, Relation[Interface::Shape::Entry]]
|
631
631
|
if sub_method = sub_interface.methods[method_name]
|
632
632
|
hash[method_name] = Relation.new(sub_type: sub_method, super_type: sup_method)
|
633
633
|
else
|
@@ -806,26 +806,23 @@ module Steep
|
|
806
806
|
super_type.type_params.empty? or raise "Expected monomorphic method type: #{super_type}"
|
807
807
|
|
808
808
|
All(relation) do |result|
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
when Relation
|
809
|
+
type_relation = Relation.new(sub_type: sub_type.type, super_type: super_type.type)
|
810
|
+
|
811
|
+
case ret = expand_block_given(name, Relation.new(sub_type: sub_type.block, super_type: super_type.block))
|
812
|
+
when true
|
813
|
+
result.add(type_relation) { check_function(name, type_relation) }
|
814
|
+
when Relation
|
815
|
+
result.add(type_relation) { check_function(name, type_relation) }
|
816
|
+
result.add(ret) do
|
818
817
|
All(ret) do |result|
|
819
818
|
result.add_result(check_self_type_binding(ret, ret.super_type.self_type, ret.sub_type.self_type))
|
820
|
-
result.add(Relation(ret.super_type.type, ret.sub_type.type)) do |
|
821
|
-
check_function(name,
|
819
|
+
result.add(Relation(ret.super_type.type, ret.sub_type.type)) do |block_relation|
|
820
|
+
check_function(name, block_relation)
|
822
821
|
end
|
823
822
|
end
|
824
|
-
when Result::Base
|
825
|
-
ret
|
826
|
-
else
|
827
|
-
nil
|
828
823
|
end
|
824
|
+
when Result::Failure
|
825
|
+
result.add { ret }
|
829
826
|
end
|
830
827
|
end
|
831
828
|
end
|
@@ -848,6 +848,15 @@ module Steep
|
|
848
848
|
|
849
849
|
constr.add_typing(node, type: type)
|
850
850
|
|
851
|
+
when :gvasgn
|
852
|
+
var_node = lhs.updated(:gvar)
|
853
|
+
send_node = rhs.updated(:send, [var_node, op, rhs])
|
854
|
+
new_node = node.updated(:gvasgn, [lhs.children[0], send_node])
|
855
|
+
|
856
|
+
type, constr = synthesize(new_node, hint: hint)
|
857
|
+
|
858
|
+
constr.add_typing(node, type: type)
|
859
|
+
|
851
860
|
when :send
|
852
861
|
new_rhs = rhs.updated(:send, [lhs, node.children[1], node.children[2]])
|
853
862
|
new_node = lhs.updated(:send, [lhs.children[0], :"#{lhs.children[1]}=", *lhs.children.drop(2), new_rhs])
|
@@ -2226,6 +2235,9 @@ module Steep
|
|
2226
2235
|
when :ivasgn
|
2227
2236
|
type, constr = synthesize(rhs, hint: hint)
|
2228
2237
|
constr.ivasgn(asgn, type)
|
2238
|
+
when :gvasgn
|
2239
|
+
type, constr = synthesize(rhs, hint: hint)
|
2240
|
+
constr.gvasgn(asgn, type)
|
2229
2241
|
when :send
|
2230
2242
|
children = asgn.children.dup
|
2231
2243
|
children[1] = :"#{children[1]}="
|
@@ -2257,27 +2269,11 @@ module Steep
|
|
2257
2269
|
yield_self do
|
2258
2270
|
name, rhs = node.children
|
2259
2271
|
lhs_type = context.type_env[name]
|
2260
|
-
|
2261
2272
|
rhs_type, constr = synthesize(rhs, hint: lhs_type).to_ary
|
2262
2273
|
|
2263
|
-
|
2264
|
-
result = constr.check_relation(sub_type: rhs_type, super_type: lhs_type)
|
2265
|
-
|
2266
|
-
if result.failure?
|
2267
|
-
constr.typing.add_error(
|
2268
|
-
Diagnostic::Ruby::IncompatibleAssignment.new(
|
2269
|
-
node: node,
|
2270
|
-
lhs_type: lhs_type,
|
2271
|
-
rhs_type: rhs_type,
|
2272
|
-
result: result
|
2273
|
-
)
|
2274
|
-
)
|
2275
|
-
end
|
2276
|
-
else
|
2277
|
-
constr.typing.add_error(Diagnostic::Ruby::UnknownGlobalVariable.new(node: node, name: name))
|
2278
|
-
end
|
2274
|
+
type, constr = constr.gvasgn(node, rhs_type)
|
2279
2275
|
|
2280
|
-
constr.add_typing(node, type:
|
2276
|
+
constr.add_typing(node, type: type)
|
2281
2277
|
end
|
2282
2278
|
|
2283
2279
|
when :gvar
|
@@ -2584,7 +2580,7 @@ module Steep
|
|
2584
2580
|
else
|
2585
2581
|
a.type
|
2586
2582
|
end
|
2587
|
-
asgn_type.nil? || asgn_type == :lvasgn || asgn_type == :ivasgn
|
2583
|
+
asgn_type.nil? || asgn_type == :lvasgn || asgn_type == :ivasgn || asgn_type == :gvasgn
|
2588
2584
|
end
|
2589
2585
|
end
|
2590
2586
|
|
@@ -2632,6 +2628,24 @@ module Steep
|
|
2632
2628
|
add_typing(node, type: rhs_type)
|
2633
2629
|
end
|
2634
2630
|
|
2631
|
+
def gvasgn(node, rhs_type)
|
2632
|
+
name = node.children[0]
|
2633
|
+
|
2634
|
+
lhs_type = context.type_env[name]
|
2635
|
+
|
2636
|
+
if lhs_type
|
2637
|
+
if result = no_subtyping?(sub_type: rhs_type, super_type: lhs_type)
|
2638
|
+
typing.add_error(
|
2639
|
+
Diagnostic::Ruby::IncompatibleAssignment.new(node: node, lhs_type: lhs_type, rhs_type: rhs_type, result: result)
|
2640
|
+
)
|
2641
|
+
end
|
2642
|
+
else
|
2643
|
+
typing.add_error(Diagnostic::Ruby::UnknownGlobalVariable.new(node: node, name: name))
|
2644
|
+
end
|
2645
|
+
|
2646
|
+
add_typing(node, type: rhs_type)
|
2647
|
+
end
|
2648
|
+
|
2635
2649
|
def type_masgn_type(mlhs_node, rhs_type, masgn:, optional:)
|
2636
2650
|
# @type var constr: TypeConstruction
|
2637
2651
|
constr = self
|
@@ -2659,7 +2673,7 @@ module Steep
|
|
2659
2673
|
when :ivasgn
|
2660
2674
|
_, constr = constr.ivasgn(asgn_node, type)
|
2661
2675
|
when :gvasgn
|
2662
|
-
|
2676
|
+
_, constr = constr.gvasgn(asgn_node, type)
|
2663
2677
|
when :mlhs
|
2664
2678
|
constr = (constr.type_masgn_type(asgn_node, type, masgn: masgn, optional: optional) or return)
|
2665
2679
|
end
|
@@ -2714,11 +2728,11 @@ module Steep
|
|
2714
2728
|
each_descendant_node(lhs) do |node|
|
2715
2729
|
case node.type
|
2716
2730
|
when :lvasgn
|
2717
|
-
_, constr = constr.lvasgn(node, AST::Builtin.any_type)
|
2731
|
+
_, constr = constr.lvasgn(node, AST::Builtin.any_type)
|
2718
2732
|
when :ivasgn
|
2719
|
-
_, constr = constr.ivasgn(node, AST::Builtin.any_type)
|
2733
|
+
_, constr = constr.ivasgn(node, AST::Builtin.any_type)
|
2720
2734
|
when :gvasgn
|
2721
|
-
|
2735
|
+
_, constr = constr.gvasgn(node, AST::Builtin.any_type)
|
2722
2736
|
else
|
2723
2737
|
_, constr = constr.add_typing(node, type: AST::Builtin.any_type).to_ary
|
2724
2738
|
end
|
data/lib/steep/version.rb
CHANGED
@@ -97,7 +97,7 @@ module Steep
|
|
97
97
|
# Returns a Relation when the given relation can be expanded to relation between Interface::Block.
|
98
98
|
# Returns a failure otherwise.
|
99
99
|
#
|
100
|
-
def expand_block_given: (Symbol name, Relation[Interface::Block?] relation) -> (Relation[Interface::Block] | true | Result::
|
100
|
+
def expand_block_given: (Symbol name, Relation[Interface::Block?] relation) -> (Relation[Interface::Block] | true | Result::Failure)
|
101
101
|
|
102
102
|
# Receives a subtyping relation between self bindings `S <: S'` that is included in procs or blocks as:
|
103
103
|
#
|
@@ -122,6 +122,8 @@ module Steep
|
|
122
122
|
|
123
123
|
def ivasgn: (Parser::AST::Node node, AST::Types::t rhs_type) -> Pair
|
124
124
|
|
125
|
+
def gvasgn: (Parser::AST::Node node, AST::Types::t rhs_type) -> Pair
|
126
|
+
|
125
127
|
def type_masgn: (Parser::AST::Node node) -> Pair
|
126
128
|
|
127
129
|
def type_masgn_type: (Parser::AST::Node mlhs_node, AST::Types::t? rhs_type, masgn: TypeInference::MultipleAssignment, optional: bool) -> TypeConstruction?
|
data/smoke/regression/Steepfile
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Enumerator::Product.new([1,2,3], ["a", "b", "c"])
|
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.4.0
|
4
|
+
version: 1.4.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: 2023-04-
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -702,6 +702,7 @@ files:
|
|
702
702
|
- smoke/regression/block_param_split.rbs
|
703
703
|
- smoke/regression/empty_yield.rb
|
704
704
|
- smoke/regression/empty_yield.rbs
|
705
|
+
- smoke/regression/enumerator_product.rb
|
705
706
|
- smoke/regression/fun.rb
|
706
707
|
- smoke/regression/fun.rbs
|
707
708
|
- smoke/regression/hash.rb
|
@@ -774,9 +775,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
774
775
|
version: 2.7.0
|
775
776
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
776
777
|
requirements:
|
777
|
-
- - "
|
778
|
+
- - ">="
|
778
779
|
- !ruby/object:Gem::Version
|
779
|
-
version:
|
780
|
+
version: '0'
|
780
781
|
requirements: []
|
781
782
|
rubygems_version: 3.4.6
|
782
783
|
signing_key:
|