steep 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1008a3723d59bab0d00afb4b385ee2752d8679461416eba84e48cc9ae479b0a4
4
- data.tar.gz: 58c470fe9d8c619d9d0767a392ab6557b6dc50b007c6c99ff6ad27a79a88ecd4
3
+ metadata.gz: 9a954088d00de93ba0f69e38e5522cc4204f4463cb973babffacb2f50bc7cfc6
4
+ data.tar.gz: 2e31ce933c1969efc22e7615b4f20f765b061a35eed001bfaa261db3421e2811
5
5
  SHA512:
6
- metadata.gz: 6f1074ca3634f9df53f361f78a4838912cb7420918f72afdb08e49ab9d64bbe97177780a54648526ff3947b36ab2f0fb2fec3fce73ed97ce0b835359c81ff52d
7
- data.tar.gz: b1c5b3fb447832fb648a56b4d827592ba0ddd719e384795786e27201a32305ce36a0d93edde61c94a311708599dd7090359bc1f15ae04ef0fa3717bd897cb580
6
+ metadata.gz: 393ff10a5ecd1170f73fef996f0928a345cedec142c7492e6629d3ea3582721ac903d2a6920ae05272550f739d104fec2c3f719bc6c29e9a1091971bd886c780
7
+ data.tar.gz: 971c80dd2959bb36fc9c6505b1a70a4af713a696471db805fb37acda66fa1acb4ff3a846e912238b4e22994fc76a3d532dce07e194f7c4a8fc7e9fa8d28a2962
@@ -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
 
@@ -288,7 +288,7 @@ module Steep
288
288
  def expand_alias(type)
289
289
  unfolded = case type
290
290
  when AST::Types::Name::Alias
291
- unfolded = unfold(type.name)
291
+ unfold(type.name)
292
292
  else
293
293
  type
294
294
  end
@@ -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
- rhs_result = synthesize(rhs, hint: hint || context.lvar_env.declared_types[name]&.type)
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 = expand_alias(hint) {|hint_| test_literal_type(node.children[0], hint_) }
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 = expand_alias(hint) {|hint| test_literal_type(node.children[0], hint) }
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 = expand_alias(hint) {|hint_| test_literal_type(node.children[0], hint_)}
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
- case hint
3026
- when AST::Types::Literal
3027
- if hint.value == literal
3028
- hint
3029
- end
3030
- when AST::Types::Union
3031
- if hint.types.any? {|ty| ty.is_a?(AST::Types::Literal) && ty.value == literal}
3032
- hint
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
@@ -1,3 +1,3 @@
1
1
  module Steep
2
- VERSION = "0.22.0"
2
+ VERSION = "0.23.0"
3
3
  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.22.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-02 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser