steep 0.25.0 → 0.27.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 +13 -0
- data/lib/steep/ast/types.rb +5 -3
- data/lib/steep/ast/types/any.rb +1 -3
- data/lib/steep/ast/types/boolean.rb +1 -3
- data/lib/steep/ast/types/bot.rb +1 -3
- data/lib/steep/ast/types/class.rb +2 -2
- data/lib/steep/ast/types/factory.rb +57 -15
- data/lib/steep/ast/types/helper.rb +6 -0
- data/lib/steep/ast/types/instance.rb +2 -2
- data/lib/steep/ast/types/intersection.rb +8 -4
- data/lib/steep/ast/types/literal.rb +1 -3
- data/lib/steep/ast/types/name.rb +13 -9
- data/lib/steep/ast/types/nil.rb +1 -3
- data/lib/steep/ast/types/proc.rb +5 -2
- data/lib/steep/ast/types/record.rb +9 -4
- data/lib/steep/ast/types/self.rb +1 -1
- data/lib/steep/ast/types/top.rb +1 -3
- data/lib/steep/ast/types/tuple.rb +5 -3
- data/lib/steep/ast/types/union.rb +8 -3
- data/lib/steep/ast/types/var.rb +2 -2
- data/lib/steep/ast/types/void.rb +1 -3
- data/lib/steep/interface/method_type.rb +48 -18
- data/lib/steep/interface/substitution.rb +32 -2
- data/lib/steep/server/base_worker.rb +4 -3
- data/lib/steep/server/master.rb +3 -1
- data/lib/steep/subtyping/check.rb +2 -3
- data/lib/steep/type_construction.rb +22 -1
- data/lib/steep/version.rb +1 -1
- data/smoke/hash/d.rb +1 -1
- data/steep.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09e364b23ebecd35868dbde7ea09938fa8208219ee1fcd19a0faaa9a160f6aab'
|
4
|
+
data.tar.gz: c4374adcf1b0c54663e04380229322d9c07865fac69b1b74fa2eeabecd26cd7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e59635b6fba6e2dac0c7ba8fb12d9a4e4734ffd95a48b8af1cb2cdbb0a5280d660c46fbf724ea48a61247165319b448598f702d6ef0dbf78d28b78dcb7ba536c
|
7
|
+
data.tar.gz: 62ca2d4504a4d75922abf3b76def89f0146a298b3452a874d98a869fa3f39942984224324cdec93f7894918b4386a07aabb4a1be6f572bcbbb5d3081086b1cda
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.27.0 (2020-08-31)
|
6
|
+
|
7
|
+
* Make tuple types _covariant_ ([#195](https://github.com/soutaro/steep/pull/195))
|
8
|
+
* Support `or_asgn`/`and_asgn` with `send` node lhs ([#194](https://github.com/soutaro/steep/pull/194))
|
9
|
+
* Performance improvement ([#193](https://github.com/soutaro/steep/pull/193))
|
10
|
+
* Add specialized versions of `#first` and `#last` on tuples ([#191](https://github.com/soutaro/steep/pull/191))
|
11
|
+
* Typing bug fix on `[]` (empty array) ([#190](https://github.com/soutaro/steep/pull/190))
|
12
|
+
* Earlier shutdown with interruption while `steep watch` ([#173](https://github.com/soutaro/steep/pull/173))
|
13
|
+
|
14
|
+
## 0.26.0
|
15
|
+
|
16
|
+
* Skipped
|
17
|
+
|
5
18
|
## 0.25.0 (2020-08-18)
|
6
19
|
|
7
20
|
* Improve `op_send` typing ([#186](https://github.com/soutaro/steep/pull/186))
|
data/lib/steep/ast/types.rb
CHANGED
@@ -35,9 +35,11 @@ module Steep
|
|
35
35
|
"masked(#{type}|#{mask})"
|
36
36
|
end
|
37
37
|
|
38
|
-
def free_variables
|
39
|
-
|
40
|
-
|
38
|
+
def free_variables
|
39
|
+
@fvs ||= Set.new.tap do |set|
|
40
|
+
set.merge(type.free_variables)
|
41
|
+
set.merge(mask.free_variables)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
def each_type(&block)
|
data/lib/steep/ast/types/any.rb
CHANGED
data/lib/steep/ast/types/bot.rb
CHANGED
@@ -4,8 +4,14 @@ module Steep
|
|
4
4
|
class Factory
|
5
5
|
attr_reader :definition_builder
|
6
6
|
|
7
|
+
attr_reader :type_name_cache
|
8
|
+
attr_reader :type_cache
|
9
|
+
|
7
10
|
def initialize(builder:)
|
8
11
|
@definition_builder = builder
|
12
|
+
|
13
|
+
@type_name_cache = {}
|
14
|
+
@type_cache = {}
|
9
15
|
end
|
10
16
|
|
11
17
|
def type_name_resolver
|
@@ -13,7 +19,9 @@ module Steep
|
|
13
19
|
end
|
14
20
|
|
15
21
|
def type(type)
|
16
|
-
|
22
|
+
ty = type_cache[type] and return ty
|
23
|
+
|
24
|
+
type_cache[type] = case type
|
17
25
|
when RBS::Types::Bases::Any
|
18
26
|
Any.new(location: nil)
|
19
27
|
when RBS::Types::Bases::Class
|
@@ -144,14 +152,17 @@ module Steep
|
|
144
152
|
end
|
145
153
|
|
146
154
|
def type_name(name)
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
+
n = type_name_cache[name] and return n
|
156
|
+
|
157
|
+
type_name_cache[name] =
|
158
|
+
(case
|
159
|
+
when name.class?
|
160
|
+
Names::Module.new(name: name.name, namespace: namespace(name.namespace), location: nil)
|
161
|
+
when name.interface?
|
162
|
+
Names::Interface.new(name: name.name, namespace: namespace(name.namespace), location: nil)
|
163
|
+
when name.alias?
|
164
|
+
Names::Alias.new(name: name.name, namespace: namespace(name.namespace), location: nil)
|
165
|
+
end)
|
155
166
|
end
|
156
167
|
|
157
168
|
def type_name_1(name)
|
@@ -190,7 +201,7 @@ module Steep
|
|
190
201
|
)
|
191
202
|
end
|
192
203
|
|
193
|
-
def method_type(method_type, self_type:)
|
204
|
+
def method_type(method_type, self_type:, subst2: nil)
|
194
205
|
fvs = self_type.free_variables()
|
195
206
|
|
196
207
|
type_params = []
|
@@ -208,6 +219,7 @@ module Steep
|
|
208
219
|
end
|
209
220
|
end
|
210
221
|
subst = Interface::Substitution.build(alpha_vars, alpha_types)
|
222
|
+
subst.merge!(subst2) if subst2
|
211
223
|
|
212
224
|
type = Interface::MethodType.new(
|
213
225
|
type_params: type_params,
|
@@ -332,7 +344,7 @@ module Steep
|
|
332
344
|
|
333
345
|
interface.methods[name] = Interface::Interface::Combination.overload(
|
334
346
|
method.method_types.map do |type|
|
335
|
-
method_type(type, self_type: self_type
|
347
|
+
method_type(type, self_type: self_type, subst2: subst)
|
336
348
|
end,
|
337
349
|
incompatible: name == :initialize || name == :new
|
338
350
|
)
|
@@ -353,9 +365,9 @@ module Steep
|
|
353
365
|
definition.methods.each do |name, method|
|
354
366
|
interface.methods[name] = Interface::Interface::Combination.overload(
|
355
367
|
method.method_types.map do |type|
|
356
|
-
method_type(type, self_type: self_type
|
368
|
+
method_type(type, self_type: self_type, subst2: subst)
|
357
369
|
end,
|
358
|
-
incompatible:
|
370
|
+
incompatible: false
|
359
371
|
)
|
360
372
|
end
|
361
373
|
end
|
@@ -379,9 +391,9 @@ module Steep
|
|
379
391
|
|
380
392
|
interface.methods[name] = Interface::Interface::Combination.overload(
|
381
393
|
method.method_types.map do |type|
|
382
|
-
method_type(type, self_type: self_type
|
394
|
+
method_type(type, self_type: self_type, subst2: subst)
|
383
395
|
end,
|
384
|
-
incompatible:
|
396
|
+
incompatible: false
|
385
397
|
)
|
386
398
|
end
|
387
399
|
end
|
@@ -468,6 +480,36 @@ module Steep
|
|
468
480
|
incompatible: false
|
469
481
|
)
|
470
482
|
end
|
483
|
+
|
484
|
+
array_interface.methods[:first] = array_interface.methods[:first].yield_self do |first|
|
485
|
+
Interface::Interface::Combination.overload(
|
486
|
+
[
|
487
|
+
Interface::MethodType.new(
|
488
|
+
type_params: [],
|
489
|
+
params: Interface::Params.empty,
|
490
|
+
block: nil,
|
491
|
+
return_type: type.types[0] || AST::Builtin.nil_type,
|
492
|
+
location: nil
|
493
|
+
)
|
494
|
+
],
|
495
|
+
incompatible: false
|
496
|
+
)
|
497
|
+
end
|
498
|
+
|
499
|
+
array_interface.methods[:last] = array_interface.methods[:last].yield_self do |last|
|
500
|
+
Interface::Interface::Combination.overload(
|
501
|
+
[
|
502
|
+
Interface::MethodType.new(
|
503
|
+
type_params: [],
|
504
|
+
params: Interface::Params.empty,
|
505
|
+
block: nil,
|
506
|
+
return_type: type.types.last || AST::Builtin.nil_type,
|
507
|
+
location: nil
|
508
|
+
)
|
509
|
+
],
|
510
|
+
incompatible: false
|
511
|
+
)
|
512
|
+
end
|
471
513
|
end
|
472
514
|
end
|
473
515
|
|
@@ -57,10 +57,14 @@ module Steep
|
|
57
57
|
"(#{types.map(&:to_s).sort.join(" & ")})"
|
58
58
|
end
|
59
59
|
|
60
|
-
def free_variables
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
def free_variables()
|
61
|
+
@fvs ||= begin
|
62
|
+
set = Set.new
|
63
|
+
types.each do |type|
|
64
|
+
set.merge(type.free_variables)
|
65
|
+
end
|
66
|
+
set
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
include Helper::ChildrenLevel
|
data/lib/steep/ast/types/name.rb
CHANGED
@@ -11,9 +11,7 @@ module Steep
|
|
11
11
|
@name = name
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
Set.new
|
16
|
-
end
|
14
|
+
include Helper::NoFreeVariables
|
17
15
|
|
18
16
|
def subst(s)
|
19
17
|
self
|
@@ -41,7 +39,7 @@ module Steep
|
|
41
39
|
alias eql? ==
|
42
40
|
|
43
41
|
def hash
|
44
|
-
self.class.hash ^ name.hash ^ args.hash
|
42
|
+
@hash ||= self.class.hash ^ name.hash ^ args.hash
|
45
43
|
end
|
46
44
|
|
47
45
|
def to_s
|
@@ -57,14 +55,20 @@ module Steep
|
|
57
55
|
end
|
58
56
|
|
59
57
|
def subst(s)
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
if free_variables.intersect?(s.domain)
|
59
|
+
self.class.new(location: location,
|
60
|
+
name: name,
|
61
|
+
args: args.map {|a| a.subst(s) })
|
62
|
+
else
|
63
|
+
self
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
67
|
def free_variables
|
66
|
-
|
67
|
-
|
68
|
+
@fvs ||= Set.new().tap do |set|
|
69
|
+
args.each do |type|
|
70
|
+
set.merge(type.free_variables)
|
71
|
+
end
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
data/lib/steep/ast/types/nil.rb
CHANGED
data/lib/steep/ast/types/proc.rb
CHANGED
@@ -36,8 +36,11 @@ module Steep
|
|
36
36
|
"^#{params} -> #{return_type}"
|
37
37
|
end
|
38
38
|
|
39
|
-
def free_variables
|
40
|
-
|
39
|
+
def free_variables()
|
40
|
+
@fvs ||= Set.new.tap do |set|
|
41
|
+
set.merge(params.free_variables)
|
42
|
+
set.merge(return_type.free_variables)
|
43
|
+
end
|
41
44
|
end
|
42
45
|
|
43
46
|
def level
|
@@ -26,12 +26,17 @@ module Steep
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_s
|
29
|
-
|
29
|
+
strings = elements.keys.sort.map do |key|
|
30
|
+
"#{key.inspect} => #{elements[key]}"
|
31
|
+
end
|
32
|
+
"{ #{strings.join(", ")} }"
|
30
33
|
end
|
31
34
|
|
32
|
-
def free_variables
|
33
|
-
|
34
|
-
|
35
|
+
def free_variables()
|
36
|
+
@fvs ||= Set.new.tap do |set|
|
37
|
+
elements.each_value do |type|
|
38
|
+
set.merge(type.free_variables)
|
39
|
+
end
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
data/lib/steep/ast/types/self.rb
CHANGED
data/lib/steep/ast/types/top.rb
CHANGED
@@ -30,9 +30,11 @@ module Steep
|
|
30
30
|
"[#{types.join(", ")}]"
|
31
31
|
end
|
32
32
|
|
33
|
-
def free_variables
|
34
|
-
|
35
|
-
|
33
|
+
def free_variables()
|
34
|
+
@fvs ||= Set.new.tap do |set|
|
35
|
+
types.each do |type|
|
36
|
+
set.merge(type.free_variables)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -11,6 +11,9 @@ module Steep
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.build(types:, location: nil)
|
14
|
+
return AST::Types::Bot.new if types.empty?
|
15
|
+
return types.first if types.size == 1
|
16
|
+
|
14
17
|
types.flat_map do |type|
|
15
18
|
if type.is_a?(Union)
|
16
19
|
type.types
|
@@ -29,7 +32,7 @@ module Steep
|
|
29
32
|
type
|
30
33
|
end
|
31
34
|
end.compact.uniq.yield_self do |tys|
|
32
|
-
case tys.
|
35
|
+
case tys.size
|
33
36
|
when 0
|
34
37
|
AST::Types::Bot.new
|
35
38
|
when 1
|
@@ -61,8 +64,10 @@ module Steep
|
|
61
64
|
end
|
62
65
|
|
63
66
|
def free_variables
|
64
|
-
|
65
|
-
|
67
|
+
@fvs ||= Set.new.tap do |set|
|
68
|
+
types.each do |type|
|
69
|
+
set.merge(type.free_variables)
|
70
|
+
end
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
data/lib/steep/ast/types/var.rb
CHANGED
data/lib/steep/ast/types/void.rb
CHANGED
@@ -211,10 +211,10 @@ module Steep
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
def free_variables
|
215
|
-
Set.new.tap do |
|
214
|
+
def free_variables()
|
215
|
+
@fvs ||= Set.new.tap do |set|
|
216
216
|
each_type do |type|
|
217
|
-
|
217
|
+
set.merge(type.free_variables)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
end
|
@@ -224,14 +224,29 @@ module Steep
|
|
224
224
|
end
|
225
225
|
|
226
226
|
def subst(s)
|
227
|
-
self.
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
)
|
227
|
+
return self if s.empty?
|
228
|
+
return self if empty?
|
229
|
+
return self if free_variables.disjoint?(s.domain)
|
230
|
+
|
231
|
+
rs = required.map {|t| t.subst(s) }
|
232
|
+
os = optional.map {|t| t.subst(s) }
|
233
|
+
r = rest&.subst(s)
|
234
|
+
rk = required_keywords.transform_values {|t| t.subst(s) }
|
235
|
+
ok = optional_keywords.transform_values {|t| t.subst(s) }
|
236
|
+
k = rest_keywords&.subst(s)
|
237
|
+
|
238
|
+
if rs == required && os == optional && r == rest && rk == required_keywords && ok == optional_keywords && k == rest_keywords
|
239
|
+
self
|
240
|
+
else
|
241
|
+
self.class.new(
|
242
|
+
required: required.map {|t| t.subst(s) },
|
243
|
+
optional: optional.map {|t| t.subst(s) },
|
244
|
+
rest: rest&.subst(s),
|
245
|
+
required_keywords: required_keywords.transform_values {|t| t.subst(s) },
|
246
|
+
optional_keywords: optional_keywords.transform_values {|t| t.subst(s) },
|
247
|
+
rest_keywords: rest_keywords&.subst(s)
|
248
|
+
)
|
249
|
+
end
|
235
250
|
end
|
236
251
|
|
237
252
|
def size
|
@@ -557,14 +572,19 @@ module Steep
|
|
557
572
|
end
|
558
573
|
|
559
574
|
def subst(s)
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
575
|
+
ty = type.subst(s)
|
576
|
+
if ty == type
|
577
|
+
self
|
578
|
+
else
|
579
|
+
self.class.new(
|
580
|
+
type: ty,
|
581
|
+
optional: optional
|
582
|
+
)
|
583
|
+
end
|
564
584
|
end
|
565
585
|
|
566
|
-
def free_variables
|
567
|
-
type.free_variables
|
586
|
+
def free_variables()
|
587
|
+
@fvs ||= type.free_variables
|
568
588
|
end
|
569
589
|
|
570
590
|
def to_s
|
@@ -617,10 +637,20 @@ module Steep
|
|
617
637
|
end
|
618
638
|
|
619
639
|
def free_variables
|
620
|
-
|
640
|
+
@fvs ||= Set.new.tap do |set|
|
641
|
+
set.merge(params.free_variables)
|
642
|
+
if block
|
643
|
+
set.merge(block.free_variables)
|
644
|
+
end
|
645
|
+
set.merge(return_type.free_variables)
|
646
|
+
set.subtract(type_params)
|
647
|
+
end
|
621
648
|
end
|
622
649
|
|
623
650
|
def subst(s)
|
651
|
+
return self if s.empty?
|
652
|
+
return self if free_variables.disjoint?(s.domain)
|
653
|
+
|
624
654
|
s_ = s.except(type_params)
|
625
655
|
|
626
656
|
self.class.new(
|
@@ -26,7 +26,32 @@ module Steep
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.empty
|
29
|
-
new(dictionary: {},
|
29
|
+
new(dictionary: {},
|
30
|
+
instance_type: INSTANCE_TYPE,
|
31
|
+
module_type: CLASS_TYPE,
|
32
|
+
self_type: SELF_TYPE)
|
33
|
+
end
|
34
|
+
|
35
|
+
def empty?
|
36
|
+
dictionary.empty? &&
|
37
|
+
instance_type.is_a?(AST::Types::Instance) &&
|
38
|
+
module_type.is_a?(AST::Types::Class) &&
|
39
|
+
self_type.is_a?(AST::Types::Self)
|
40
|
+
end
|
41
|
+
|
42
|
+
INSTANCE_TYPE = AST::Types::Instance.new
|
43
|
+
CLASS_TYPE = AST::Types::Class.new
|
44
|
+
SELF_TYPE = AST::Types::Self.new
|
45
|
+
|
46
|
+
def domain
|
47
|
+
set = Set.new
|
48
|
+
|
49
|
+
set.merge(dictionary.keys)
|
50
|
+
set << INSTANCE_TYPE unless instance_type.is_a?(AST::Types::Instance)
|
51
|
+
set << CLASS_TYPE unless instance_type.is_a?(AST::Types::Class)
|
52
|
+
set << SELF_TYPE unless instance_type.is_a?(AST::Types::Self)
|
53
|
+
|
54
|
+
set
|
30
55
|
end
|
31
56
|
|
32
57
|
def to_s
|
@@ -81,6 +106,11 @@ module Steep
|
|
81
106
|
raise "Duplicated key on merge!: #{key}, #{a}, #{b}"
|
82
107
|
end
|
83
108
|
end
|
109
|
+
|
110
|
+
@instance_type = instance_type.subst(s)
|
111
|
+
@module_type = module_type.subst(s)
|
112
|
+
@self_type = self_type.subst(s)
|
113
|
+
|
84
114
|
self
|
85
115
|
end
|
86
116
|
|
@@ -92,7 +122,7 @@ module Steep
|
|
92
122
|
end
|
93
123
|
|
94
124
|
def add!(v, ty)
|
95
|
-
merge!(Substitution.new(dictionary: { v => ty }, instance_type:
|
125
|
+
merge!(Substitution.new(dictionary: { v => ty }, instance_type: instance_type, module_type: module_type, self_type: self_type))
|
96
126
|
end
|
97
127
|
end
|
98
128
|
end
|
@@ -12,6 +12,7 @@ module Steep
|
|
12
12
|
@project = project
|
13
13
|
@reader = reader
|
14
14
|
@writer = writer
|
15
|
+
@shutdown = false
|
15
16
|
end
|
16
17
|
|
17
18
|
def handle_request(request)
|
@@ -28,7 +29,7 @@ module Steep
|
|
28
29
|
Steep.logger.formatter.push_tags(*tags)
|
29
30
|
Steep.logger.tagged "background" do
|
30
31
|
while job = queue.pop
|
31
|
-
handle_job(job)
|
32
|
+
handle_job(job) unless @shutdown
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
@@ -38,11 +39,11 @@ module Steep
|
|
38
39
|
reader.read do |request|
|
39
40
|
case request[:method]
|
40
41
|
when "shutdown"
|
41
|
-
|
42
|
+
@shutdown = true
|
42
43
|
when "exit"
|
43
44
|
break
|
44
45
|
else
|
45
|
-
handle_request(request)
|
46
|
+
handle_request(request) unless @shutdown
|
46
47
|
end
|
47
48
|
end
|
48
49
|
ensure
|
data/lib/steep/server/master.rb
CHANGED
@@ -23,6 +23,7 @@ module Steep
|
|
23
23
|
@signature_worker = signature_worker
|
24
24
|
@code_workers = code_workers
|
25
25
|
@worker_to_paths = {}
|
26
|
+
@shutdown = false
|
26
27
|
end
|
27
28
|
|
28
29
|
def start
|
@@ -59,7 +60,7 @@ module Steep
|
|
59
60
|
end
|
60
61
|
|
61
62
|
while job = queue.pop
|
62
|
-
writer.write(job)
|
63
|
+
writer.write(job) unless @shutdown
|
63
64
|
end
|
64
65
|
|
65
66
|
writer.io.close
|
@@ -154,6 +155,7 @@ module Steep
|
|
154
155
|
|
155
156
|
when "shutdown"
|
156
157
|
queue << { id: id, result: nil }
|
158
|
+
@shutdown = true
|
157
159
|
|
158
160
|
when "exit"
|
159
161
|
queue << nil
|
@@ -302,10 +302,9 @@ module Steep
|
|
302
302
|
when relation.sub_type.is_a?(AST::Types::Tuple) && relation.super_type.is_a?(AST::Types::Tuple)
|
303
303
|
if relation.sub_type.types.size >= relation.super_type.types.size
|
304
304
|
pairs = relation.sub_type.types.take(relation.super_type.types.size).zip(relation.super_type.types)
|
305
|
-
results = pairs.
|
305
|
+
results = pairs.map do |t1, t2|
|
306
306
|
relation = Relation.new(sub_type: t1, super_type: t2)
|
307
|
-
|
308
|
-
check(relation.flip, self_type: self_type, assumption: assumption, trace: trace, constraints: constraints)]
|
307
|
+
check(relation, self_type: self_type, assumption: assumption, trace: trace, constraints: constraints)
|
309
308
|
end
|
310
309
|
|
311
310
|
if results.all?(&:success?)
|
@@ -1800,13 +1800,34 @@ module Steep
|
|
1800
1800
|
when :or_asgn, :and_asgn
|
1801
1801
|
yield_self do
|
1802
1802
|
asgn, rhs = node.children
|
1803
|
-
type, constr = synthesize(rhs, hint: hint)
|
1804
1803
|
|
1805
1804
|
case asgn.type
|
1806
1805
|
when :lvasgn
|
1806
|
+
type, constr = synthesize(rhs, hint: hint)
|
1807
1807
|
constr.lvasgn(asgn, type)
|
1808
1808
|
when :ivasgn
|
1809
|
+
type, constr = synthesize(rhs, hint: hint)
|
1809
1810
|
constr.ivasgn(asgn, type)
|
1811
|
+
when :send
|
1812
|
+
rhs_ = node.updated(:send,
|
1813
|
+
[
|
1814
|
+
asgn.children[0],
|
1815
|
+
:"#{asgn.children[1]}=",
|
1816
|
+
asgn.children[2],
|
1817
|
+
rhs
|
1818
|
+
])
|
1819
|
+
node_type = case node.type
|
1820
|
+
when :or_asgn
|
1821
|
+
:or
|
1822
|
+
when :and_asgn
|
1823
|
+
:and
|
1824
|
+
end
|
1825
|
+
node_ = node.updated(node_type, [asgn, rhs_])
|
1826
|
+
|
1827
|
+
synthesize(node_, hint: hint)
|
1828
|
+
else
|
1829
|
+
Steep.logger.error { "#{node.type} with #{asgn.type} lhs is not supported"}
|
1830
|
+
fallback_to_any(node)
|
1810
1831
|
end
|
1811
1832
|
end
|
1812
1833
|
|
data/lib/steep/version.rb
CHANGED
data/smoke/hash/d.rb
CHANGED
@@ -2,5 +2,5 @@
|
|
2
2
|
|
3
3
|
params = { id: 30, name: "Matz" }
|
4
4
|
|
5
|
-
# !expects IncompatibleAssignment: lhs_type={ :
|
5
|
+
# !expects IncompatibleAssignment: lhs_type={ :id => ::Integer, :name => ::String }, rhs_type={ :email => ::String, :id => ::String, :name => ::String }
|
6
6
|
params = { id: "30", name: "foo", email: "matsumoto@soutaro.com" }
|
data/steep.gemspec
CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
|
35
35
|
spec.add_runtime_dependency "listen", "~> 3.1"
|
36
36
|
spec.add_runtime_dependency "language_server-protocol", "~> 3.14.0.2"
|
37
|
-
spec.add_runtime_dependency "rbs", "~> 0.
|
37
|
+
spec.add_runtime_dependency "rbs", "~> 0.11.0"
|
38
38
|
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: 0.
|
4
|
+
version: 0.27.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-08-
|
11
|
+
date: 2020-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -106,14 +106,14 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.
|
109
|
+
version: 0.11.0
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
116
|
+
version: 0.11.0
|
117
117
|
description: Gradual Typing for Ruby
|
118
118
|
email:
|
119
119
|
- matsumoto@soutaro.com
|