sorbet-runtime 0.5.5753 → 0.5.5756
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/types/typed_enumerable.rb +12 -2
- 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: bd7293e2ecb1fff8bfffe575f54692501e6e674a2262b48a29292efbbfd28c89
|
4
|
+
data.tar.gz: 2af039a64a0a3a40215b07254fd9449d735534791bd19951fb66258e47d3e31f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb769579394ffc85ef9a94504667ce7570799324c732894d74e10a4aa53cd6aea12452357b21110dd2267113765ad646b7760d5e2e9d78d31ea8392df55864a
|
7
|
+
data.tar.gz: 549bb245c5451836ad92de7f74882c82426722bc029afd8ef828ae3cbad6f19d22cfe0373dcddbbc3d84905a2558369bda5a4e1ef151cafe2c14a501787a810a
|
@@ -50,7 +50,11 @@ module T::Types
|
|
50
50
|
# Enumerators can be unbounded: see `[:foo, :bar].cycle`
|
51
51
|
return true
|
52
52
|
when Range
|
53
|
-
|
53
|
+
# A nil beginning or a nil end does not provide any type information. That is, nil in a range represents
|
54
|
+
# boundlessness, it does not express a type. For example `(nil...nil)` is not a T::Range[NilClass], its a range
|
55
|
+
# of unknown types (T::Range[T.untyped]).
|
56
|
+
# Similarly, `(nil...1)` is not a `T::Range[T.nilable(Integer)]`, it's a boundless range of Integer.
|
57
|
+
(obj.begin.nil? || @type.valid?(obj.begin)) && (obj.end.nil? || @type.valid?(obj.end))
|
54
58
|
when Set
|
55
59
|
obj.each do |item|
|
56
60
|
return false unless @type.valid?(item)
|
@@ -124,7 +128,13 @@ module T::Types
|
|
124
128
|
inferred_val = type_from_instances(obj.values)
|
125
129
|
T::Hash[inferred_key, inferred_val]
|
126
130
|
when Range
|
127
|
-
|
131
|
+
# We can't get any information from `NilClass` in ranges (since nil is used to represent boundlessness).
|
132
|
+
typeable_objects = [obj.begin, obj.end].compact
|
133
|
+
if typeable_objects.empty?
|
134
|
+
T::Range[T.untyped]
|
135
|
+
else
|
136
|
+
T::Range[type_from_instances(typeable_objects)]
|
137
|
+
end
|
128
138
|
when Enumerator
|
129
139
|
T::Enumerator[type_from_instances(obj)]
|
130
140
|
when Set
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5756
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|