steep 1.6.0.pre.1 → 1.6.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 +18 -0
- data/Gemfile.lock +2 -2
- data/lib/steep/diagnostic/ruby.rb +4 -4
- data/lib/steep/interface/builder.rb +27 -13
- data/lib/steep/project/pattern.rb +1 -1
- data/lib/steep/services/completion_provider.rb +1 -1
- data/lib/steep/type_construction.rb +13 -2
- data/lib/steep/version.rb +1 -1
- data/sig/steep/project/pattern.rbs +22 -0
- 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: 89c50cdd644b4f90f2b7f5a18c262c181088eda18b116b7604f8ca4b4d17363c
|
4
|
+
data.tar.gz: 6191d664a4a348dfdc43559c40a75ded920b83a2b245d28d10f84c3c72f7d324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 833394273e491c154a8fd6ca60c693f1fd28f51d4dcb2f864c4d60abe4645e7dceb4d9914261d8237fb339e0c7f27a7625baedea3cd9ac1680d0d32a98b2867c
|
7
|
+
data.tar.gz: 827261fdcffe5a0d3b32ee5771bbc6577a7a9b71a0aa2f25f3cff5eb1c6a2817e592a56f6c7189d8a028a686b7a1d8e24b313e919427c253f372de3316ed6353
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.6.0.pre.3 (2023-11-01)
|
6
|
+
|
7
|
+
### Type checker core
|
8
|
+
|
9
|
+
* Object methods are moved to Kernel ([#952](https://github.com/soutaro/steep/pull/952))
|
10
|
+
* Check if `rescue` body has `bot` type ([#953](https://github.com/soutaro/steep/pull/953))
|
11
|
+
|
12
|
+
## 1.6.0.pre.2 (2023-10-31)
|
13
|
+
|
14
|
+
### Type checker core
|
15
|
+
|
16
|
+
* Assign types on method calls in mlhs node ([#951](https://github.com/soutaro/steep/pull/951))
|
17
|
+
* Change severity of block diagnostics ([#950](https://github.com/soutaro/steep/pull/950))
|
18
|
+
|
19
|
+
### Commandline tool
|
20
|
+
|
21
|
+
* Match with `**` in pattern ([#949](https://github.com/soutaro/steep/pull/949))
|
22
|
+
|
5
23
|
## 1.6.0.pre.1 (2023-10-27)
|
6
24
|
|
7
25
|
### Type checker core
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
steep (1.6.0.pre.
|
4
|
+
steep (1.6.0.pre.3)
|
5
5
|
activesupport (>= 5.1)
|
6
6
|
concurrent-ruby (>= 1.1.10)
|
7
7
|
csv (>= 3.0.9)
|
@@ -68,7 +68,7 @@ GEM
|
|
68
68
|
stringio
|
69
69
|
racc (1.7.1)
|
70
70
|
rainbow (3.1.1)
|
71
|
-
rake (13.0
|
71
|
+
rake (13.1.0)
|
72
72
|
rb-fsevent (0.11.2)
|
73
73
|
rb-inotify (0.10.1)
|
74
74
|
ffi (~> 1.0)
|
@@ -1013,8 +1013,8 @@ module Steep
|
|
1013
1013
|
@default ||= _ = all_error.merge(
|
1014
1014
|
{
|
1015
1015
|
ArgumentTypeMismatch => :error,
|
1016
|
-
BlockBodyTypeMismatch => :
|
1017
|
-
BlockTypeMismatch => :
|
1016
|
+
BlockBodyTypeMismatch => :warning,
|
1017
|
+
BlockTypeMismatch => :warning,
|
1018
1018
|
BreakTypeMismatch => :hint,
|
1019
1019
|
DifferentMethodParameterKind => :hint,
|
1020
1020
|
FallbackAny => :hint,
|
@@ -1129,8 +1129,8 @@ module Steep
|
|
1129
1129
|
@lenient ||= _ = all_error.merge(
|
1130
1130
|
{
|
1131
1131
|
ArgumentTypeMismatch => :information,
|
1132
|
-
BlockBodyTypeMismatch => :
|
1133
|
-
BlockTypeMismatch => :
|
1132
|
+
BlockBodyTypeMismatch => :information,
|
1133
|
+
BlockTypeMismatch => :information,
|
1134
1134
|
BreakTypeMismatch => :hint,
|
1135
1135
|
DifferentMethodParameterKind => nil,
|
1136
1136
|
FallbackAny => nil,
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Steep
|
3
2
|
module Interface
|
4
3
|
class Builder
|
@@ -718,22 +717,30 @@ module Steep
|
|
718
717
|
if member.is_a?(RBS::AST::Members::MethodDefinition)
|
719
718
|
case method_name.method_name
|
720
719
|
when :is_a?, :kind_of?, :instance_of?
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
720
|
+
case
|
721
|
+
when RBS::BuiltinNames::Object.name,
|
722
|
+
RBS::BuiltinNames::Kernel.name
|
723
|
+
if member.instance?
|
724
|
+
return method_type.with(
|
725
|
+
type: method_type.type.with(
|
726
|
+
return_type: AST::Types::Logic::ReceiverIsArg.new(location: method_type.type.return_type.location)
|
727
|
+
)
|
725
728
|
)
|
726
|
-
|
729
|
+
end
|
727
730
|
end
|
728
731
|
|
729
732
|
when :nil?
|
730
733
|
case defined_in
|
731
|
-
when RBS::BuiltinNames::Object.name,
|
732
|
-
|
733
|
-
|
734
|
-
|
734
|
+
when RBS::BuiltinNames::Object.name,
|
735
|
+
AST::Builtin::NilClass.module_name,
|
736
|
+
RBS::BuiltinNames::Kernel.name
|
737
|
+
if member.instance?
|
738
|
+
return method_type.with(
|
739
|
+
type: method_type.type.with(
|
740
|
+
return_type: AST::Types::Logic::ReceiverIsNil.new(location: method_type.type.return_type.location)
|
741
|
+
)
|
735
742
|
)
|
736
|
-
|
743
|
+
end
|
737
744
|
end
|
738
745
|
|
739
746
|
when :!
|
@@ -757,8 +764,14 @@ module Steep
|
|
757
764
|
return_type: AST::Types::Logic::ArgIsReceiver.new(location: method_type.type.return_type.location)
|
758
765
|
)
|
759
766
|
)
|
760
|
-
when RBS::BuiltinNames::Object.name,
|
761
|
-
RBS::BuiltinNames::
|
767
|
+
when RBS::BuiltinNames::Object.name,
|
768
|
+
RBS::BuiltinNames::Kernel.name,
|
769
|
+
RBS::BuiltinNames::String.name,
|
770
|
+
RBS::BuiltinNames::Integer.name,
|
771
|
+
RBS::BuiltinNames::Symbol.name,
|
772
|
+
RBS::BuiltinNames::TrueClass.name,
|
773
|
+
RBS::BuiltinNames::FalseClass.name,
|
774
|
+
TypeName("::NilClass")
|
762
775
|
# Value based type-case works on literal types which is available for String, Integer, Symbol, TrueClass, FalseClass, and NilClass
|
763
776
|
return method_type.with(
|
764
777
|
type: method_type.type.with(
|
@@ -783,3 +796,4 @@ module Steep
|
|
783
796
|
end
|
784
797
|
end
|
785
798
|
end
|
799
|
+
|
@@ -48,7 +48,7 @@ module Steep
|
|
48
48
|
string = path.to_s
|
49
49
|
extension = path.extname
|
50
50
|
|
51
|
-
patterns.any? {|pat| File.fnmatch(pat, string) } ||
|
51
|
+
patterns.any? {|pat| File.fnmatch(pat, string, File::FNM_PATHNAME) } ||
|
52
52
|
prefixes.any? {|prefix| string.start_with?(prefix) && extension == ext }
|
53
53
|
end
|
54
54
|
end
|
@@ -663,7 +663,7 @@ module Steep
|
|
663
663
|
if parent
|
664
664
|
case parent.type
|
665
665
|
when :const
|
666
|
-
const_name = typing.source_index.reference(constant_node: parent)
|
666
|
+
const_name = typing.source_index.reference(constant_node: parent) or raise "Unknown node in source_index: #{parent}"
|
667
667
|
consts = context.type_env.constant_env.children(const_name)
|
668
668
|
end
|
669
669
|
else
|
@@ -2214,6 +2214,10 @@ module Steep
|
|
2214
2214
|
end
|
2215
2215
|
end
|
2216
2216
|
|
2217
|
+
resbody_pairs.select! do |pair|
|
2218
|
+
no_subtyping?(sub_type: pair.type, super_type: AST::Types::Bot.new)
|
2219
|
+
end
|
2220
|
+
|
2217
2221
|
resbody_types = resbody_pairs.map(&:type)
|
2218
2222
|
resbody_envs = resbody_pairs.map {|pair| pair.context.type_env }
|
2219
2223
|
|
@@ -2225,8 +2229,13 @@ module Steep
|
|
2225
2229
|
.update_type_env {|env| env.join(*resbody_envs, env) }
|
2226
2230
|
.add_typing(node, type: union_type(else_type, *resbody_types))
|
2227
2231
|
else
|
2228
|
-
|
2229
|
-
|
2232
|
+
if resbody_types.empty?
|
2233
|
+
constr = body_pair ? body_pair.constr : self
|
2234
|
+
constr.add_typing(node, type: body_pair&.type || AST::Builtin.nil_type)
|
2235
|
+
else
|
2236
|
+
update_type_env {|env| env.join(*resbody_envs, else_constr.context.type_env) }
|
2237
|
+
.add_typing(node, type: union_type(*[body_pair&.type, *resbody_types].compact))
|
2238
|
+
end
|
2230
2239
|
end
|
2231
2240
|
end
|
2232
2241
|
|
@@ -2908,6 +2917,8 @@ module Steep
|
|
2908
2917
|
_, constr = constr.gvasgn(asgn_node, type)
|
2909
2918
|
when :mlhs
|
2910
2919
|
constr = (constr.type_masgn_type(asgn_node, type, masgn: masgn, optional: optional) or return)
|
2920
|
+
else
|
2921
|
+
_, constr = constr.synthesize_children(asgn_node).add_typing(asgn_node, type: AST::Builtin.any_type)
|
2911
2922
|
end
|
2912
2923
|
|
2913
2924
|
if node.type == :splat
|
data/lib/steep/version.rb
CHANGED
@@ -1,22 +1,44 @@
|
|
1
1
|
module Steep
|
2
2
|
class Project
|
3
|
+
# `Pattern` class represents a pair of *positive* and *negative* patterns that may match with a pathname
|
4
|
+
#
|
5
|
+
# ```rb
|
6
|
+
# pat = Pattern.new(patterns: ["app/models"], ignores: ["app/models/account.rb"], ext: ".rbs")
|
7
|
+
#
|
8
|
+
# pat =~ "app/models/group.rb" # => true
|
9
|
+
# pat =~ "app/models/account.rb" # => false
|
10
|
+
# ```
|
11
|
+
#
|
12
|
+
# The pattern may be:
|
13
|
+
#
|
14
|
+
# 1. Directory name pattern -- `lib`, or
|
15
|
+
# 2. *Glob* pattern -- `foo/**/bar.rb`
|
16
|
+
#
|
3
17
|
class Pattern
|
18
|
+
# Positive patterns, which is tested with `fnmatch`
|
4
19
|
attr_reader patterns: Array[String]
|
5
20
|
|
21
|
+
# Negative patterns, which is tested with `fnmatch`
|
6
22
|
attr_reader ignores: Array[String]
|
7
23
|
|
24
|
+
# Positive *dir name* pattern constructed from `#patterns`, which is tested with `start_with?`
|
8
25
|
attr_reader prefixes: Array[String]
|
9
26
|
|
27
|
+
# Negative *dir name* pattern constructed from `#ignores`, which is tested with `start_with?`
|
10
28
|
attr_reader ignore_prefixes: Array[String]
|
11
29
|
|
12
30
|
attr_reader ext: String
|
13
31
|
|
14
32
|
def initialize: (patterns: Array[String], ext: String, ?ignores: Array[String]) -> void
|
15
33
|
|
34
|
+
# Returns `true` if given path matches to *positive* pattern, but doesn't match to *negative* pattern
|
35
|
+
#
|
16
36
|
def =~: (Pathname | String path) -> bool
|
17
37
|
|
38
|
+
# Returns true if given `Pathname` matches to *positive* pattern
|
18
39
|
def match?: (Pathname path) -> bool
|
19
40
|
|
41
|
+
# Returns true if given `Pathname` matches to *negative* pattern
|
20
42
|
def ignore?: (Pathname path) -> bool
|
21
43
|
|
22
44
|
def test_string: (Pathname path, Array[String] patterns, Array[String] prefixes) -> bool
|
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.6.0.pre.
|
4
|
+
version: 1.6.0.pre.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-
|
11
|
+
date: 2023-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|