steep 0.22.0 → 0.23.0
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/CHANGELOG.md +6 -1
- data/lib/steep/ast/types/factory.rb +1 -1
- data/lib/steep/subtyping/check.rb +9 -9
- data/lib/steep/type_construction.rb +14 -12
- data/lib/steep/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a954088d00de93ba0f69e38e5522cc4204f4463cb973babffacb2f50bc7cfc6
|
4
|
+
data.tar.gz: 2e31ce933c1969efc22e7615b4f20f765b061a35eed001bfaa261db3421e2811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393ff10a5ecd1170f73fef996f0928a345cedec142c7492e6629d3ea3582721ac903d2a6920ae05272550f739d104fec2c3f719bc6c29e9a1091971bd886c780
|
7
|
+
data.tar.gz: 971c80dd2959bb36fc9c6505b1a70a4af713a696471db805fb37acda66fa1acb4ff3a846e912238b4e22994fc76a3d532dce07e194f7c4a8fc7e9fa8d28a2962
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.23.0 (2020-08-06)
|
6
|
+
|
7
|
+
* Fix literal typing with hint ([#179](https://github.com/soutaro/steep/pull/179))
|
8
|
+
* Fix literal type subtyping ([#178](https://github.com/soutaro/steep/pull/178))
|
9
|
+
|
5
10
|
## 0.22.0 (2020-08-03)
|
6
11
|
|
7
12
|
* Improve signature validation ([#175](https://github.com/soutaro/steep/pull/175), [#177](https://github.com/soutaro/steep/pull/177))
|
@@ -51,7 +56,7 @@
|
|
51
56
|
|
52
57
|
* Fix constant resolution ([#143](https://github.com/soutaro/steep/pull/143))
|
53
58
|
* Fix RBS diagnostics line number in LSP ([#142](https://github.com/soutaro/steep/pull/142))
|
54
|
-
* Fix crash caused by hover on `def` in LSP ([#140](https://github.com/soutaro/steep/pull/140))
|
59
|
+
* Fix crash caused by hover on `def` in LSP ([#140](https://github.com/soutaro/steep/pull/140))
|
55
60
|
|
56
61
|
## 0.16.0 (2020-05-19)
|
57
62
|
|
@@ -180,15 +180,6 @@ module Steep
|
|
180
180
|
constraints: constraints
|
181
181
|
)
|
182
182
|
|
183
|
-
when relation.sub_type.is_a?(AST::Types::Literal)
|
184
|
-
check(
|
185
|
-
Relation.new(sub_type: relation.sub_type.back_type, super_type: relation.super_type),
|
186
|
-
self_type: self_type,
|
187
|
-
assumption: assumption,
|
188
|
-
trace: trace,
|
189
|
-
constraints: constraints
|
190
|
-
)
|
191
|
-
|
192
183
|
when relation.sub_type.is_a?(AST::Types::Union)
|
193
184
|
results = relation.sub_type.types.map do |sub_type|
|
194
185
|
check(Relation.new(sub_type: sub_type, super_type: relation.super_type),
|
@@ -386,6 +377,15 @@ module Steep
|
|
386
377
|
when relation.sub_type.is_a?(AST::Types::Nil) && AST::Builtin::NilClass.instance_type?(relation.super_type)
|
387
378
|
success(constraints: constraints)
|
388
379
|
|
380
|
+
when relation.sub_type.is_a?(AST::Types::Literal)
|
381
|
+
check(
|
382
|
+
Relation.new(sub_type: relation.sub_type.back_type, super_type: relation.super_type),
|
383
|
+
self_type: self_type,
|
384
|
+
assumption: assumption,
|
385
|
+
trace: trace,
|
386
|
+
constraints: constraints
|
387
|
+
)
|
388
|
+
|
389
389
|
else
|
390
390
|
failure(error: Result::Failure::UnknownPairError.new(relation: relation),
|
391
391
|
trace: trace)
|
@@ -638,7 +638,8 @@ module Steep
|
|
638
638
|
when :__skip__
|
639
639
|
add_typing(node, type: AST::Builtin.any_type)
|
640
640
|
else
|
641
|
-
|
641
|
+
hint ||= context.lvar_env.declared_types[name]&.type
|
642
|
+
rhs_result = synthesize(rhs, hint: hint)
|
642
643
|
|
643
644
|
constr = rhs_result.constr.update_lvar_env do |lvar_env|
|
644
645
|
lvar_env.assign(name, node: node, type: rhs_result.type) do |declared_type, actual_type, result|
|
@@ -1062,7 +1063,7 @@ module Steep
|
|
1062
1063
|
|
1063
1064
|
when :int
|
1064
1065
|
yield_self do
|
1065
|
-
literal_type =
|
1066
|
+
literal_type = test_literal_type(node.children[0], hint)
|
1066
1067
|
|
1067
1068
|
if literal_type
|
1068
1069
|
add_typing(node, type: literal_type)
|
@@ -1073,7 +1074,7 @@ module Steep
|
|
1073
1074
|
|
1074
1075
|
when :sym
|
1075
1076
|
yield_self do
|
1076
|
-
literal_type =
|
1077
|
+
literal_type = test_literal_type(node.children[0], hint)
|
1077
1078
|
|
1078
1079
|
if literal_type
|
1079
1080
|
add_typing(node, type: literal_type)
|
@@ -1084,7 +1085,7 @@ module Steep
|
|
1084
1085
|
|
1085
1086
|
when :str
|
1086
1087
|
yield_self do
|
1087
|
-
literal_type =
|
1088
|
+
literal_type = test_literal_type(node.children[0], hint)
|
1088
1089
|
|
1089
1090
|
if literal_type
|
1090
1091
|
add_typing(node, type: literal_type)
|
@@ -3022,14 +3023,15 @@ module Steep
|
|
3022
3023
|
end
|
3023
3024
|
|
3024
3025
|
def test_literal_type(literal, hint)
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3026
|
+
if hint
|
3027
|
+
case hint
|
3028
|
+
when AST::Types::Any
|
3029
|
+
nil
|
3030
|
+
else
|
3031
|
+
literal_type = AST::Types::Literal.new(value: literal, location: nil)
|
3032
|
+
if check_relation(sub_type: literal_type, super_type: hint).success?
|
3033
|
+
hint
|
3034
|
+
end
|
3033
3035
|
end
|
3034
3036
|
end
|
3035
3037
|
end
|
data/lib/steep/version.rb
CHANGED
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.23.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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|