steep 1.10.0.pre.1 → 1.10.0.pre.3
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 +15 -0
- data/Rakefile +23 -0
- data/lib/steep/diagnostic/signature.rb +28 -0
- data/lib/steep/source.rb +1 -1
- data/lib/steep/type_construction.rb +37 -10
- data/lib/steep/type_inference/context.rb +4 -0
- 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: d2f331bc22e08a6a06be70e413f4eb99361a2c868d6f38f1d4f05fc21778fc21
|
4
|
+
data.tar.gz: 3c6a8f14f8596926d4add8de3f7cdc72c27c6a47d90faadae4e4485c1f241dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e89df803b5c799cb50eb4a2e115f9dd189addfda847facfc87538a6cd46dd99fc87cff71a7c7939f97cce05a1e8b123b3ac289540c96ef6f23595bd2bea8a0a
|
7
|
+
data.tar.gz: 2e1844ebaf2e597b57bccf1b65bc3a97708e1f5b964daeb609fc4f692e4c92f64ca27f767ea4ac89178484c8ce8ca6d593d74117dfaff82dcf664874ca1495aa
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.10.0.pre.3 (2025-03-14)
|
4
|
+
|
5
|
+
### Type checker core
|
6
|
+
|
7
|
+
* Fix block type checking ([#1534](https://github.com/soutaro/steep/pull/1534))
|
8
|
+
|
9
|
+
## 1.10.0.pre.2 (2025-03-14)
|
10
|
+
|
11
|
+
### Type checker core
|
12
|
+
|
13
|
+
* Fix `self` type handling at block-self-hint ([#1531](https://github.com/soutaro/steep/pull/1531))
|
14
|
+
* Delay type variable resolution on method call with blocks ([#1530](https://github.com/soutaro/steep/pull/1530))
|
15
|
+
* Fix type checking block calls on `untyped` receiver ([#1528](https://github.com/soutaro/steep/pull/1528))
|
16
|
+
* Catch the message of VariableDuplicationError ([#1521](https://github.com/soutaro/steep/pull/1521))
|
17
|
+
|
3
18
|
## 1.10.0.pre.1 (2025-03-11)
|
4
19
|
|
5
20
|
### Type checker core
|
data/Rakefile
CHANGED
@@ -224,3 +224,26 @@ NOTES
|
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
227
|
+
|
228
|
+
namespace :rbs do
|
229
|
+
task :watch do
|
230
|
+
require "listen"
|
231
|
+
listener = Listen.to('test') do |modified, added, removed|
|
232
|
+
paths = (modified + added).map do
|
233
|
+
Pathname(_1).relative_path_from(Pathname.pwd)
|
234
|
+
end
|
235
|
+
sh "rbs-inline", "--opt-out", "--output=sig", *paths.map(&:to_s)
|
236
|
+
end
|
237
|
+
listener.start
|
238
|
+
begin
|
239
|
+
sleep
|
240
|
+
rescue Interrupt
|
241
|
+
listener.stop
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
task :generate do
|
246
|
+
sh "rbs-inline --opt-out --output=sig test"
|
247
|
+
sh "rbs-inline --opt-out --output=tmp/rbs-inline bin/generate-diagnostics-docs.rb"
|
248
|
+
end
|
249
|
+
end
|
@@ -273,6 +273,30 @@ module Steep
|
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
276
|
+
class VariableDuplicationError < Base
|
277
|
+
attr_reader :type_name
|
278
|
+
attr_reader :variable_name
|
279
|
+
attr_reader :location
|
280
|
+
|
281
|
+
def initialize(type_name:, variable_name:, location:)
|
282
|
+
@type_name = type_name
|
283
|
+
@variable_name = variable_name
|
284
|
+
@location = location
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
class InstanceVariableDuplicationError < VariableDuplicationError
|
289
|
+
def header_line
|
290
|
+
"Duplicated instance variable name `#{variable_name}` in `#{type_name}`"
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
class ClassInstanceVariableDuplicationError < VariableDuplicationError
|
295
|
+
def header_line
|
296
|
+
"Duplicated class instance variable name `#{variable_name}` in `#{type_name}`"
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
276
300
|
class ClassVariableDuplicationError < Base
|
277
301
|
attr_reader :class_name
|
278
302
|
attr_reader :other_class_name
|
@@ -581,6 +605,10 @@ module Steep
|
|
581
605
|
Diagnostic::Signature::CyclicClassAliasDefinitionError.new(decl: error.alias_entry.decl)
|
582
606
|
when RBS::TypeParamDefaultReferenceError
|
583
607
|
Diagnostic::Signature::TypeParamDefaultReferenceError.new(error.type_param, location: error.location)
|
608
|
+
when RBS::InstanceVariableDuplicationError
|
609
|
+
Diagnostic::Signature::InstanceVariableDuplicationError.new(type_name: error.type_name, variable_name: error.variable_name, location: error.location)
|
610
|
+
when RBS::ClassInstanceVariableDuplicationError
|
611
|
+
Diagnostic::Signature::ClassInstanceVariableDuplicationError.new(type_name: error.type_name, variable_name: error.variable_name, location: error.location)
|
584
612
|
else
|
585
613
|
raise error
|
586
614
|
end
|
data/lib/steep/source.rb
CHANGED
@@ -257,7 +257,7 @@ module Steep
|
|
257
257
|
annot.line or next
|
258
258
|
|
259
259
|
case node.type
|
260
|
-
when :def, :module, :class, :block, :ensure, :defs, :resbody
|
260
|
+
when :def, :module, :class, :block, :numblock, :ensure, :defs, :resbody
|
261
261
|
location = node.loc
|
262
262
|
location.line <= annot.line && annot.line < location.last_line
|
263
263
|
else
|
@@ -3108,7 +3108,7 @@ module Steep
|
|
3108
3108
|
body_node,
|
3109
3109
|
block_params: params,
|
3110
3110
|
block_param_hint: params_hint,
|
3111
|
-
|
3111
|
+
block_next_type: return_hint,
|
3112
3112
|
block_block_hint: block_hint,
|
3113
3113
|
block_annotations: block_annotations,
|
3114
3114
|
block_self_hint: self_hint,
|
@@ -3458,7 +3458,7 @@ module Steep
|
|
3458
3458
|
block_annotations = source.annotations(block: node, factory: checker.factory, context: nesting)
|
3459
3459
|
block_params or raise
|
3460
3460
|
|
3461
|
-
constr = constr.synthesize_children(node.children[0])
|
3461
|
+
constr = constr.synthesize_children(node.children[0], skips: [receiver])
|
3462
3462
|
|
3463
3463
|
constr.type_block_without_hint(
|
3464
3464
|
node: node,
|
@@ -4064,7 +4064,7 @@ module Steep
|
|
4064
4064
|
block_body,
|
4065
4065
|
block_params: block_params_,
|
4066
4066
|
block_param_hint: method_type.block.type.params,
|
4067
|
-
|
4067
|
+
block_next_type: method_type.block.type.return_type,
|
4068
4068
|
block_block_hint: nil,
|
4069
4069
|
block_annotations: block_annotations,
|
4070
4070
|
block_self_hint: method_type.block.self_type,
|
@@ -4119,6 +4119,15 @@ module Steep
|
|
4119
4119
|
|
4120
4120
|
fvs_.merge(method_type.type.params.free_variables) if method_type.type.params
|
4121
4121
|
fvs_.merge(method_type.block.type.params.free_variables) if method_type.block.type.params
|
4122
|
+
(method_type.type.return_type.free_variables + method_type.block.type.return_type.free_variables).each do |var|
|
4123
|
+
if var.is_a?(Symbol)
|
4124
|
+
if constraints.unknown?(var)
|
4125
|
+
unless constraints.has_constraint?(var)
|
4126
|
+
fvs_.delete(var)
|
4127
|
+
end
|
4128
|
+
end
|
4129
|
+
end
|
4130
|
+
end
|
4122
4131
|
|
4123
4132
|
constraints.solution(checker, variables: fvs_, context: ccontext)
|
4124
4133
|
}
|
@@ -4130,7 +4139,7 @@ module Steep
|
|
4130
4139
|
block_constr = block_constr.update_type_env {|env| env.subst(s) }
|
4131
4140
|
block_constr = block_constr.update_context {|context|
|
4132
4141
|
context.with(
|
4133
|
-
self_type:
|
4142
|
+
self_type: context.self_type.subst(s),
|
4134
4143
|
type_env: context.type_env.subst(s),
|
4135
4144
|
block_context: context.block_context&.subst(s),
|
4136
4145
|
break_context: context.break_context&.subst(s)
|
@@ -4426,7 +4435,7 @@ module Steep
|
|
4426
4435
|
block_body,
|
4427
4436
|
block_params: block_params,
|
4428
4437
|
block_param_hint: nil,
|
4429
|
-
|
4438
|
+
block_next_type: nil,
|
4430
4439
|
block_block_hint: nil,
|
4431
4440
|
block_annotations: block_annotations,
|
4432
4441
|
block_self_hint: nil,
|
@@ -4479,7 +4488,7 @@ module Steep
|
|
4479
4488
|
end
|
4480
4489
|
end
|
4481
4490
|
|
4482
|
-
def for_block(body_node, block_params:, block_param_hint:,
|
4491
|
+
def for_block(body_node, block_params:, block_param_hint:, block_next_type:, block_block_hint:, block_annotations:, node_type_hint:, block_self_hint:)
|
4483
4492
|
block_param_pairs = block_param_hint && block_params.zip(block_param_hint, block_block_hint, factory: checker.factory)
|
4484
4493
|
|
4485
4494
|
# @type var param_types_hash: Hash[Symbol?, AST::Types::t]
|
@@ -4568,19 +4577,18 @@ module Steep
|
|
4568
4577
|
end
|
4569
4578
|
|
4570
4579
|
block_context = TypeInference::Context::BlockContext.new(
|
4571
|
-
body_type: block_annotations.block_type
|
4580
|
+
body_type: block_annotations.block_type
|
4572
4581
|
)
|
4573
4582
|
break_context = TypeInference::Context::BreakContext.new(
|
4574
4583
|
break_type: break_type || AST::Builtin.any_type,
|
4575
|
-
next_type:
|
4584
|
+
next_type: block_next_type || AST::Builtin.any_type
|
4576
4585
|
)
|
4577
4586
|
|
4578
|
-
self_type =
|
4587
|
+
self_type = block_self_hint || self.self_type
|
4579
4588
|
module_context = self.module_context
|
4580
4589
|
|
4581
4590
|
if implements = block_annotations.implement_module_annotation
|
4582
4591
|
module_context = default_module_context(implements.name, nesting: nesting)
|
4583
|
-
|
4584
4592
|
self_type = module_context.module_type
|
4585
4593
|
end
|
4586
4594
|
|
@@ -4588,6 +4596,11 @@ module Steep
|
|
4588
4596
|
self_type = annotation_self_type
|
4589
4597
|
end
|
4590
4598
|
|
4599
|
+
# self_type here means the top-level `self` type because of the `Interface::Builder` implementation
|
4600
|
+
if self_type
|
4601
|
+
self_type = expand_self(self_type)
|
4602
|
+
end
|
4603
|
+
|
4591
4604
|
self.class.new(
|
4592
4605
|
checker: checker,
|
4593
4606
|
source: source,
|
@@ -4610,6 +4623,20 @@ module Steep
|
|
4610
4623
|
if block_body
|
4611
4624
|
body_type, _, context = synthesize(block_body, hint: block_context&.body_type || block_type_hint)
|
4612
4625
|
|
4626
|
+
if annotated_body_type = block_context&.body_type
|
4627
|
+
if result = no_subtyping?(sub_type: body_type, super_type: annotated_body_type)
|
4628
|
+
typing.add_error(
|
4629
|
+
Diagnostic::Ruby::BlockBodyTypeMismatch.new(
|
4630
|
+
node: node,
|
4631
|
+
expected: annotated_body_type,
|
4632
|
+
actual: body_type,
|
4633
|
+
result: result
|
4634
|
+
)
|
4635
|
+
)
|
4636
|
+
end
|
4637
|
+
body_type = annotated_body_type
|
4638
|
+
end
|
4639
|
+
|
4613
4640
|
range = block_body.loc.expression.end_pos..node.loc.end.begin_pos
|
4614
4641
|
typing.cursor_context.set(range, context)
|
4615
4642
|
|
@@ -155,6 +155,10 @@ module Steep
|
|
155
155
|
@type_env = type_env
|
156
156
|
@call_context = call_context
|
157
157
|
@variable_context = variable_context
|
158
|
+
|
159
|
+
if self_type.free_variables.include?(AST::Types::Self.instance)
|
160
|
+
raise "Context#self_type cannot contain `self`"
|
161
|
+
end
|
158
162
|
end
|
159
163
|
|
160
164
|
def with(method_context: self.method_context,
|
data/lib/steep/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.0.pre.
|
4
|
+
version: 1.10.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-14 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: parser
|