steep 1.5.1 → 1.5.3

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: d7775c9db83acf70b19f27b4983923ee40e8d1a39043c981726573b0c06eb1c8
4
- data.tar.gz: 1d9f2753a19a577cce778f6ec1ee924534523812764c0350c21280d82a0e1c69
3
+ metadata.gz: c6fac293e42dfa305b98aa0f8dbf49acdad88f0794a6081f7c6e548ccab49f4b
4
+ data.tar.gz: 2824c6289d92fadc1d062571d9652d759fc7774531d532d2bcf846ce20240bec
5
5
  SHA512:
6
- metadata.gz: 6bd6340dfecc114df47a959d25a4201a87ccccbc0b1e59238962de51c28218b01aa25499ae8a760e678481192131dfdd3c99b6c89412ce4b6e0b3fad2bf34ca5
7
- data.tar.gz: 87437181a053c65f297192eb9e339c0b58ad074d4c6716eef2a1019116d3ed06d0525eebcc49855ae99a8393bffac82640d77f608479b98f67e158b42c54d327
6
+ metadata.gz: 800d77371db9fcc77688a30c442355d84f31cbbf21ccc7fda46155e394b011887b98b1c47f3f9a9a117087c4790a3fecfee9ac4bdbfb4dea096deafa959e2d96
7
+ data.tar.gz: 2d1eed9a3397eeeb1c5675a7038acbf5cdab173aec3285d8c88df925f9fe7d07bf4ef0f248ae7df5895bef21509bc0e2156883c84a7bdb4a53598b1608041864
@@ -8,6 +8,13 @@ updates:
8
8
  time: "20:00"
9
9
  open-pull-requests-limit: 10
10
10
 
11
+ - package-ecosystem: bundler
12
+ directory: "/gemfile_steep"
13
+ schedule:
14
+ interval: daily
15
+ time: "20:00"
16
+ open-pull-requests-limit: 10
17
+
11
18
  - package-ecosystem: "github-actions"
12
19
  directory: "/"
13
20
  schedule:
data/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.5.3 (2023-08-10)
6
+
7
+ ### Type checker core
8
+
9
+ * Fix type checking parenthesized conditional nodes ([#896](https://github.com/soutaro/steep/pull/896))
10
+
11
+ ## 1.5.2 (2023-07-27)
12
+
13
+ ### Type checker core
14
+
15
+ * Avoid inifinite loop in `#shape` ([#884](https://github.com/soutaro/steep/pull/884))
16
+ * Fix `nil?` typing with `untyped` receiver ([#882](https://github.com/soutaro/steep/pull/882))
17
+
18
+ ### Language server
19
+
20
+ * Avoid breaking the original source code through `CompletionProvider` ([#883](https://github.com/soutaro/steep/pull/883))
21
+
5
22
  ## 1.5.1 (2023-07-20)
6
23
 
7
24
  ### Type checker core
data/Gemfile CHANGED
@@ -4,13 +4,9 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "rake"
7
- gem "minitest", "~> 5.18"
7
+ gem "minitest", "~> 5.19"
8
8
  gem "minitest-hooks"
9
9
  group :stackprof, optional: true do
10
10
  gem "stackprof"
11
11
  end
12
12
  gem 'minitest-slow_test'
13
-
14
- group :development do
15
- gem "ruby-lsp", require: false
16
- end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- steep (1.5.1)
4
+ steep (1.5.3)
5
5
  activesupport (>= 5.1)
6
6
  concurrent-ruby (>= 1.1.10)
7
7
  csv (>= 3.0.9)
@@ -20,7 +20,7 @@ PATH
20
20
  GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
- activesupport (7.0.6)
23
+ activesupport (7.0.7)
24
24
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
25
  i18n (>= 1.6, < 2)
26
26
  minitest (>= 5.1)
@@ -38,32 +38,24 @@ GEM
38
38
  rb-fsevent (~> 0.10, >= 0.10.3)
39
39
  rb-inotify (~> 0.9, >= 0.9.10)
40
40
  logger (1.5.3)
41
- minitest (5.18.1)
42
- minitest-hooks (1.5.0)
41
+ minitest (5.19.0)
42
+ minitest-hooks (1.5.1)
43
43
  minitest (> 5.3)
44
44
  minitest-slow_test (0.2.0)
45
45
  minitest (>= 5.0)
46
46
  parser (3.2.2.3)
47
47
  ast (~> 2.4.1)
48
48
  racc
49
- prettier_print (1.2.1)
50
49
  racc (1.7.1)
51
50
  rainbow (3.1.1)
52
51
  rake (13.0.6)
53
52
  rb-fsevent (0.11.2)
54
53
  rb-inotify (0.10.1)
55
54
  ffi (~> 1.0)
56
- rbs (3.1.1)
57
- ruby-lsp (0.5.1)
58
- language_server-protocol (~> 3.17.0)
59
- sorbet-runtime
60
- syntax_tree (>= 6.1.1, < 7)
55
+ rbs (3.1.3)
61
56
  securerandom (0.2.2)
62
- sorbet-runtime (0.5.10832)
63
57
  stackprof (0.2.25)
64
58
  strscan (3.0.6)
65
- syntax_tree (6.1.1)
66
- prettier_print (>= 1.2.0)
67
59
  terminal-table (3.0.2)
68
60
  unicode-display_width (>= 1.1.1, < 3)
69
61
  tzinfo (2.0.6)
@@ -74,11 +66,10 @@ PLATFORMS
74
66
  ruby
75
67
 
76
68
  DEPENDENCIES
77
- minitest (~> 5.18)
69
+ minitest (~> 5.19)
78
70
  minitest-hooks
79
71
  minitest-slow_test
80
72
  rake
81
- ruby-lsp
82
73
  stackprof
83
74
  steep!
84
75
 
data/Gemfile.steep CHANGED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'steep', require: false
data/bin/rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  BINSTUB_DIR=$(cd $(dirname $0); pwd)
4
- GEMFILE=$(readlink -f ${BINSTUB_DIR}/../Gemfile.steep)
4
+ GEMFILE=$(readlink -f ${BINSTUB_DIR}/../gemfile_steep/Gemfile)
5
5
  COLLECTION=$(readlink -f ${BINSTUB_DIR}/../rbs_collection.steep.yaml)
6
6
  ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)
7
7
 
data/bin/setup CHANGED
@@ -5,5 +5,5 @@ set -vx
5
5
 
6
6
  bundle install
7
7
 
8
- bundle install --gemfile=Gemfile.steep
8
+ bundle install --gemfile=gemfile_steep/Gemfile
9
9
  bin/rbs collection install
data/bin/steep CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  BINSTUB_DIR=$(cd $(dirname $0); pwd)
4
- GEMFILE=$(readlink -f ${BINSTUB_DIR}/../Gemfile.steep)
4
+ GEMFILE=$(readlink -f ${BINSTUB_DIR}/../gemfile_steep/Gemfile)
5
5
  ROOT_DIR=$(readlink -f ${BINSTUB_DIR}/..)
6
6
 
7
7
  STEEP="bundle exec --gemfile=${GEMFILE} steep"
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'steep', require: false
@@ -19,7 +19,7 @@ GEM
19
19
  rb-fsevent (~> 0.10, >= 0.10.3)
20
20
  rb-inotify (~> 0.9, >= 0.9.10)
21
21
  logger (1.5.3)
22
- minitest (5.18.1)
22
+ minitest (5.19.0)
23
23
  parser (3.2.2.3)
24
24
  ast (~> 2.4.1)
25
25
  racc
@@ -28,9 +28,9 @@ GEM
28
28
  rb-fsevent (0.11.2)
29
29
  rb-inotify (0.10.1)
30
30
  ffi (~> 1.0)
31
- rbs (3.1.1)
31
+ rbs (3.1.2)
32
32
  securerandom (0.2.2)
33
- steep (1.5.0)
33
+ steep (1.5.2)
34
34
  activesupport (>= 5.1)
35
35
  concurrent-ruby (>= 1.1.10)
36
36
  csv (>= 3.0.9)
@@ -55,6 +55,7 @@ GEM
55
55
  PLATFORMS
56
56
  arm64-darwin-21
57
57
  arm64-darwin-22
58
+ x86_64-linux
58
59
 
59
60
  DEPENDENCIES
60
61
  steep
@@ -68,6 +68,24 @@ module Steep
68
68
  )
69
69
  end
70
70
  end
71
+
72
+ def self_type?
73
+ unless self_type.is_a?(AST::Types::Self)
74
+ self_type
75
+ end
76
+ end
77
+
78
+ def instance_type?
79
+ unless instance_type.is_a?(AST::Types::Instance)
80
+ instance_type
81
+ end
82
+ end
83
+
84
+ def class_type?
85
+ unless class_type.is_a?(AST::Types::Class)
86
+ class_type
87
+ end
88
+ end
71
89
  end
72
90
 
73
91
  attr_reader :factory, :cache, :raw_object_cache
@@ -122,16 +140,18 @@ module Steep
122
140
  fetch_cache(type, public_only, config) do
123
141
  case type
124
142
  when AST::Types::Self
125
- self_type = config.self_type.subst(config.subst)
126
- shape(self_type, public_only: public_only, config: config.update(resolve_self: false))
143
+ if self_type = config.self_type?
144
+ self_type = self_type.subst(config.subst)
145
+ shape(self_type, public_only: public_only, config: config.update(resolve_self: false))
146
+ end
127
147
  when AST::Types::Instance
128
- if config.instance_type
129
- instance_type = config.instance_type.subst(config.subst)
148
+ if instance_type = config.instance_type?
149
+ instance_type = instance_type.subst(config.subst)
130
150
  shape(instance_type, public_only: public_only, config: config.update(resolve_instance: false))
131
151
  end
132
152
  when AST::Types::Class
133
- if config.class_type
134
- class_type = config.class_type.subst(config.subst)
153
+ if class_type = config.class_type?
154
+ class_type = class_type.subst(config.subst)
135
155
  shape(class_type, public_only: public_only, config: config.update(resolve_class: false))
136
156
  end
137
157
  when AST::Types::Name::Instance, AST::Types::Name::Interface, AST::Types::Name::Singleton
@@ -159,7 +179,7 @@ module Steep
159
179
  instance_var = AST::Types::Var.fresh(:INSTANCE)
160
180
 
161
181
  bounds = config.variable_bounds.merge({ self_var.name => config.self_type, instance_var.name => config.instance_type, class_var.name => config.class_type })
162
- type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var))
182
+ type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var)) #: AST::Types::Union
163
183
 
164
184
  config_ = config.update(resolve_self: false, resolve_class: true, resolve_instance: true, variable_bounds: bounds)
165
185
 
@@ -203,7 +223,7 @@ module Steep
203
223
  instance_var = AST::Types::Var.fresh(:INSTANCE)
204
224
 
205
225
  bounds = config.variable_bounds.merge({ self_var.name => config.self_type, instance_var.name => config.instance_type, class_var.name => config.class_type })
206
- type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var))
226
+ type_ = type.subst(Substitution.build([], [], self_type: self_var, instance_type: instance_var, module_type: class_var)) #: AST::Types::Intersection
207
227
 
208
228
  config_ = config.update(resolve_self: false, resolve_class: true, resolve_instance: true, variable_bounds: bounds)
209
229
 
@@ -244,6 +244,9 @@ module Steep
244
244
 
245
245
  rescue Parser::SyntaxError => exn
246
246
  Steep.logger.info "recovering syntax error: #{exn.inspect}"
247
+
248
+ @source_text = source_text.dup
249
+
247
250
  case possible_trigger
248
251
  when "."
249
252
  if source_text[index-2] == "&"
@@ -710,7 +710,7 @@ module Steep
710
710
  end
711
711
  end
712
712
 
713
- p = pair.constr.synthesize(last_node, hint: hint)
713
+ p = pair.constr.synthesize(last_node, hint: hint, condition: condition)
714
714
  last_pair = pair + p
715
715
  last_pair.constr.add_typing(node, type: last_pair.type, constr: last_pair.constr)
716
716
  else
@@ -292,7 +292,7 @@ module Steep
292
292
  )
293
293
 
294
294
  truthy_result = Result.new(type: TRUE, env: truthy_env, unreachable: false)
295
- truthy_result.unreachable! if unwrap == receiver_type
295
+ truthy_result.unreachable! if no_subtyping?(sub_type: AST::Builtin.nil_type, super_type: receiver_type)
296
296
 
297
297
  falsy_result = Result.new(type: FALSE, env: falsy_env, unreachable: false)
298
298
  falsy_result.unreachable! unless unwrap
@@ -529,15 +529,14 @@ module Steep
529
529
  # 3. K <: T (example: T = Numeric, K = Integer)
530
530
  # 4. none of the above (example: T = String, K = Integer)
531
531
 
532
- relation = Subtyping::Relation.new(sub_type: type, super_type: instance_type)
533
- if subtyping.check(relation, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.instance, instance_type: AST::Types::Instance.instance, class_type: AST::Types::Class.instance).success?
532
+ if subtyping?(sub_type: type, super_type: instance_type)
534
533
  # 1 or 2. Satisfies the condition, no narrowing because `type` is already more specific than/equals to `instance_type`
535
534
  [
536
535
  [type],
537
536
  []
538
537
  ]
539
538
  else
540
- if subtyping.check(relation.flip, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.instance, instance_type: AST::Types::Instance.instance, class_type: AST::Types::Class.instance).success?
539
+ if subtyping?(sub_type: instance_type, super_type: type)
541
540
  # 3. Satisfied the condition, narrows to `instance_type`, but cannot remove it from *falsy* list
542
541
  [
543
542
  [instance_type],
@@ -554,6 +553,19 @@ module Steep
554
553
  end
555
554
  end
556
555
 
556
+ def no_subtyping?(sub_type:, super_type:)
557
+ relation = Subtyping::Relation.new(sub_type: sub_type, super_type: super_type)
558
+ result = subtyping.check(relation, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.instance, instance_type: AST::Types::Instance.instance, class_type: AST::Types::Class.instance)
559
+
560
+ if result.failure?
561
+ result
562
+ end
563
+ end
564
+
565
+ def subtyping?(sub_type:, super_type:)
566
+ !no_subtyping?(sub_type: sub_type, super_type: super_type)
567
+ end
568
+
557
569
  def try_convert(type, method)
558
570
  if shape = subtyping.builder.shape(type, public_only: true, config: config)
559
571
  if entry = shape.methods[method]
data/lib/steep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steep
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.3"
3
3
  end
@@ -103,4 +103,4 @@ gems:
103
103
  version: '0'
104
104
  source:
105
105
  type: stdlib
106
- gemfile_lock_path: Gemfile.steep.lock
106
+ gemfile_lock_path: gemfile_steep/Gemfile.lock
@@ -71,6 +71,18 @@ module Steep
71
71
 
72
72
  # Substitution for immediate type expressions
73
73
  def subst: () -> Substitution
74
+
75
+ # Returns `self_type`, or `nil` when it is `Types::Self`
76
+ #
77
+ def self_type?: () -> AST::Types::t?
78
+
79
+ # Returns `class_type`, or `nil` when it is `Types::Class`
80
+ #
81
+ def class_type?: () -> AST::Types::t?
82
+
83
+ # Returns `instanc_type`, or `nil` when it is `Types::Instance`
84
+ #
85
+ def instance_type?: () -> AST::Types::t?
74
86
  end
75
87
 
76
88
  attr_reader factory: AST::Types::Factory
@@ -99,6 +99,10 @@ module Steep
99
99
  def type_case_select0: (AST::Types::t `type`, RBS::TypeName klass) -> [Array[AST::Types::t], Array[AST::Types::t]]
100
100
 
101
101
  def try_convert: (AST::Types::t, Symbol) -> AST::Types::t?
102
+
103
+ def no_subtyping?: (sub_type: AST::Types::t, super_type: AST::Types::t) -> Subtyping::Result::t?
104
+
105
+ def subtyping?: (sub_type: AST::Types::t, super_type: AST::Types::t) -> bool
102
106
  end
103
107
  end
104
108
  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: 1.5.1
4
+ version: 1.5.3
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-07-20 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -242,7 +242,6 @@ files:
242
242
  - Gemfile
243
243
  - Gemfile.lock
244
244
  - Gemfile.steep
245
- - Gemfile.steep.lock
246
245
  - LICENSE
247
246
  - README.md
248
247
  - Rakefile
@@ -255,6 +254,8 @@ files:
255
254
  - bin/steep
256
255
  - bin/steep-prof
257
256
  - exe/steep
257
+ - gemfile_steep/Gemfile
258
+ - gemfile_steep/Gemfile.lock
258
259
  - guides/README.md
259
260
  - guides/src/gem-rbs-collection/gem-rbs-collection.md
260
261
  - guides/src/getting-started/getting-started.md