rbs 1.3.3 → 1.4.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: 7bd9429b1384739e9aae5f7b2c1d19ee02b6ea34b49e4a17a60df270acc484a0
4
- data.tar.gz: 931456b6cb01870a8ac178115effe3d13f8ce8e5968a94954b702c4c7a1f3645
3
+ metadata.gz: '019689814b3a1a5d0c1b88e2fc433acb328795f7b71c0a42889ac79bab50eb23'
4
+ data.tar.gz: d7669d77ad9fcd0a211586b9f4cfcdeaee51c22d53c98f439da69a0321728021
5
5
  SHA512:
6
- metadata.gz: c8b595190e9c69217b56d494859d759caa545bd4902a7a2f4ae679bc34720d5e64385b40f48cd77191ea1fe5c06237cd1774372d20abf7d3530308e1648ddd9c
7
- data.tar.gz: b85b23a46f0cd32fc4b45a90cd5f82b7029d9c37a36af0ccf26e61ae36cd43e0ca71e5c77350546e141e404abf4e8027f43f80b31de371e19aef9379f9a825ab
6
+ metadata.gz: 01101a55594365a082d5ed34ac6ca58e94ad79f275efb94e22cc381578755f210e14a984f77bc63c7eab118967c3f6774051b5c67a034ded2635a0081f19dc48
7
+ data.tar.gz: 4ebe708ff34901816c8d0dfd012e9e68b7fe28e65b4a7c6101ef4f1ef284e9a44c103287f40f0f7582f93bda3f4b8a85a1c834dbff01a4b3758791d3b9388087
data/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.4.0 (2021-08-19)
6
+
7
+ This release includes feature enhancements including recursive `type` definition validation, improved compatibility of global variable names, and various method type updates.
8
+
9
+ ### Signature updates
10
+
11
+ * openssl ([\#743](https://github.com/ruby/rbs/pull/743))
12
+ * `Array`, `Enumerator`, `Enumerable`, `Hash`, `FalseClass`, `Float`, `Hash`, `Integer`, `Object`, `Range`, `TrueClass` ([\#728](https://github.com/ruby/rbs/pull/728))
13
+ * `Array#[]` ([\#732](https://github.com/ruby/rbs/pull/732))
14
+ * `Exception#set_backtrace` ([\#738](https://github.com/ruby/rbs/pull/738))
15
+ * `Kernel#Array` ([\#733](https://github.com/ruby/rbs/pull/733))
16
+ * `Kernel#spawn` ([\#748](https://github.com/ruby/rbs/pull/748))
17
+ * `Kernel#String` ([\#745](https://github.com/ruby/rbs/pull/745), [\#751](https://github.com/ruby/rbs/pull/751))
18
+ * `URI::Generic#fragment` ([\#752](https://github.com/ruby/rbs/pull/752))
19
+ * `URI::Generic#merge` ([\#746](https://github.com/ruby/rbs/pull/746))
20
+
21
+ ### Language updates
22
+
23
+ * Add global variables signature ([\#749](https://github.com/ruby/rbs/pull/749))
24
+
25
+ ### Library changes
26
+
27
+ * Add Recursiive type alias defnition validation ([\#719](https://github.com/ruby/rbs/pull/719))
28
+ * Generate included modules with complete name ([\#731](https://github.com/ruby/rbs/pull/731))
29
+ * Fix `rbs-prototype-rb` error when multi assign with const ([\#740](https://github.com/ruby/rbs/pull/740))
30
+
5
31
  ## 1.3.3 (2021-07-28)
6
32
 
7
33
  This release includes a minor update of `resolv` library RBS and a fix of test for `ruby/ruby` CI.
data/Rakefile CHANGED
@@ -63,6 +63,10 @@ task :validate => :parser do
63
63
  lib << "timeout"
64
64
  end
65
65
 
66
+ if lib == ["openssl"]
67
+ lib << "socket"
68
+ end
69
+
66
70
  sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
67
71
  end
68
72
  end
data/core/array.rbs CHANGED
@@ -452,7 +452,7 @@ class Array[unchecked out Elem] < Object
452
452
  #
453
453
  def []: (int index) -> Elem
454
454
  | (int start, int length) -> ::Array[Elem]?
455
- | (::Range[::Integer] range) -> ::Array[Elem]?
455
+ | (::Range[::Integer?] range) -> ::Array[Elem]?
456
456
 
457
457
  # Element Assignment --- Sets the element at `index`, or replaces a subarray
458
458
  # from the `start` index for `length` elements, or replaces a subarray specified
@@ -486,9 +486,9 @@ class Array[unchecked out Elem] < Object
486
486
  | (int start, int length, Elem obj) -> Elem
487
487
  | (int start, int length, ::Array[Elem]) -> ::Array[Elem]
488
488
  | (int start, int length, nil) -> nil
489
- | (::Range[::Integer], Elem obj) -> Elem
490
- | (::Range[::Integer], ::Array[Elem]) -> ::Array[Elem]
491
- | (::Range[::Integer], nil) -> nil
489
+ | (::Range[::Integer?], Elem obj) -> Elem
490
+ | (::Range[::Integer?], ::Array[Elem]) -> ::Array[Elem]
491
+ | (::Range[::Integer?], nil) -> nil
492
492
 
493
493
  # See also Enumerable#all?
494
494
  #
@@ -576,7 +576,8 @@ class Array[unchecked out Elem] < Object
576
576
  # true/false, or always return a number. It is undefined which value is
577
577
  # actually picked up at each iteration.
578
578
  #
579
- def bsearch: () { (Elem) -> (true | false) } -> Elem?
579
+ def bsearch: () -> ::Enumerator[Elem, Elem?]
580
+ | () { (Elem) -> (true | false) } -> Elem?
580
581
  | () { (Elem) -> ::Integer } -> Elem?
581
582
 
582
583
  # By using binary search, finds an index of a value from this array which meets
@@ -855,7 +856,7 @@ class Array[unchecked out Elem] < Object
855
856
  # 0 -- 1 -- 2 --
856
857
  #
857
858
  def each_index: () { (::Integer index) -> void } -> self
858
- | () -> ::Enumerator[Elem, self]
859
+ | () -> ::Enumerator[::Integer, self]
859
860
 
860
861
  # Returns `true` if `self` contains no elements.
861
862
  #
@@ -1585,7 +1586,7 @@ class Array[unchecked out Elem] < Object
1585
1586
  # a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
1586
1587
  #
1587
1588
  def sample: (?random: _Rand rng) -> Elem?
1588
- | (?int n, ?random: _Rand rng) -> ::Array[Elem]
1589
+ | (int n, ?random: _Rand rng) -> ::Array[Elem]
1589
1590
 
1590
1591
  # Returns a new array containing all elements of `ary` for which the given
1591
1592
  # `block` returns a true value.
data/core/enumerable.rbs CHANGED
@@ -48,7 +48,8 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
48
48
  def collect: [U] () { (Elem arg0) -> U } -> ::Array[U]
49
49
  | () -> ::Enumerator[Elem, ::Array[untyped]]
50
50
 
51
- def collect_concat: [U] () { (Elem arg0) -> ::Enumerator[U, untyped] } -> ::Array[U]
51
+ def collect_concat: [U] () { (Elem) -> (::Array[U] | U) } -> ::Array[U]
52
+ | () -> ::Enumerator[Elem, ::Array[untyped]]
52
53
 
53
54
  # Returns the number of items in `enum` through enumeration. If an
54
55
  # argument is given, the number of items in `enum` that are equal to
@@ -79,11 +80,11 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
79
80
  def each_cons: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
80
81
  | (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
81
82
 
82
- def each_with_index: () { (Elem arg0, Integer arg1) -> untyped } -> void
83
- | () -> ::Enumerator[[ Elem, Integer ], void]
83
+ def each_with_index: () { (Elem, Integer index) -> untyped } -> self
84
+ | () -> ::Enumerator[[ Elem, Integer ], self]
84
85
 
85
- def each_with_object: [U] (U arg0) { (Elem arg0, untyped arg1) -> untyped } -> U
86
- | [U] (U arg0) -> ::Enumerator[[ Elem, U ], U]
86
+ def each_with_object: [U] (U obj) { (Elem, U obj) -> untyped } -> U
87
+ | [U] (U obj) -> ::Enumerator[[ Elem, U ], U]
87
88
 
88
89
  # Returns an array containing the items in *enum* .
89
90
  #
@@ -102,7 +103,7 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
102
103
  alias select find_all
103
104
  alias filter find_all
104
105
 
105
- def find_index: (?untyped value) -> Integer?
106
+ def find_index: (untyped value) -> Integer?
106
107
  | () { (Elem) -> boolish } -> Integer?
107
108
  | () -> ::Enumerator[Elem, Integer?]
108
109
 
@@ -123,8 +124,8 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
123
124
  def grep: (untyped arg0) -> ::Array[Elem]
124
125
  | [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
125
126
 
126
- def grep_v: (untyped arg0) -> ::Array[Integer]
127
- | [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
127
+ def grep_v: (untyped) -> ::Array[Elem]
128
+ | [U] (untyped) { (Elem) -> U } -> ::Array[U]
128
129
 
129
130
  def group_by: [U] () { (Elem arg0) -> U } -> ::Hash[U, ::Array[Elem]]
130
131
  | () -> ::Enumerator[Elem, ::Array[Elem]]
@@ -410,8 +411,8 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
410
411
  def zip: [Elem2] (::Enumerable[Elem2] enum) -> ::Array[[Elem, Elem2 | nil]]
411
412
  | [U, Elem2] (::Enumerable[Elem2]) { ([Elem, Elem2 | nil]) -> U } -> nil
412
413
 
413
- def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[U, Array[Elem]], void]
414
- | () -> ::Enumerator[Elem, Enumerator[untyped, untyped]]
414
+ def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[U, ::Array[Elem]], void]
415
+ | () -> ::Enumerator[Elem, ::Enumerator[[untyped, ::Array[Elem]], void]]
415
416
 
416
417
  def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
417
418
 
data/core/enumerator.rbs CHANGED
@@ -238,8 +238,8 @@ class Enumerator[unchecked out Elem, out Return] < Object
238
238
  def with_index: (?Integer offset) { (Elem arg0, Integer arg1) -> untyped } -> Return
239
239
  | (?Integer offset) -> ::Enumerator[[ Elem, Integer ], Return]
240
240
 
241
- def with_object: [U] (U arg0) { (Elem arg0, U arg1) -> untyped } -> U
242
- | [U] (U arg0) -> ::Enumerator[[ Elem, U ], Return]
241
+ def with_object: [U] (U obj) { (Elem, U obj) -> untyped } -> U
242
+ | [U] (U obj) -> ::Enumerator[[ Elem, U ], U]
243
243
  end
244
244
 
245
245
  class Enumerator::Generator[out Elem] < Object
data/core/exception.rbs CHANGED
@@ -185,6 +185,7 @@ class Exception < Object
185
185
  def message: () -> String
186
186
 
187
187
  def set_backtrace: (String | ::Array[String] arg0) -> ::Array[String]
188
+ | (nil) -> nil
188
189
 
189
190
  # Returns exception’s message (or the name of the exception if no message
190
191
  # is set).
data/core/false_class.rbs CHANGED
@@ -5,12 +5,12 @@
5
5
  class FalseClass
6
6
  public
7
7
 
8
- def !: () -> bool
8
+ def !: () -> true
9
9
 
10
10
  # And---Returns `false`. *obj* is always evaluated as it is the argument to a
11
11
  # method call---there is no short-circuit evaluation in this case.
12
12
  #
13
- def &: (untyped obj) -> bool
13
+ def &: (untyped obj) -> false
14
14
 
15
15
  # Case Equality -- For class Object, effectively the same as calling `#==`, but
16
16
  # typically overridden by descendants to provide meaningful semantics in `case`
@@ -24,7 +24,7 @@ class FalseClass
24
24
  #
25
25
  def ^: (nil) -> false
26
26
  | (false) -> false
27
- | (untyped obj) -> bool
27
+ | (untyped obj) -> true
28
28
 
29
29
  alias inspect to_s
30
30
 
@@ -36,5 +36,5 @@ class FalseClass
36
36
  #
37
37
  def |: (nil) -> false
38
38
  | (false) -> false
39
- | (untyped obj) -> bool
39
+ | (untyped obj) -> true
40
40
  end
data/core/float.rbs CHANGED
@@ -180,7 +180,7 @@ class Float < Numeric
180
180
  # 1.2.coerce(3) #=> [3.0, 1.2]
181
181
  # 2.5.coerce(1.1) #=> [1.1, 2.5]
182
182
  #
183
- def coerce: (Numeric) -> [Numeric, Numeric]
183
+ def coerce: (Numeric) -> [Float, Float]
184
184
 
185
185
  def conj: () -> Float
186
186
 
@@ -0,0 +1,180 @@
1
+ # The Exception object set by Kernel#raise.
2
+ $!: Exception | nil
3
+
4
+ # The array contains the module names loaded by require.
5
+ $": Array[String]
6
+
7
+ # The process number of the Ruby running this script. Same as Process.pid.
8
+ $$: Integer
9
+
10
+ # The string matched by the last successful match.
11
+ $&: String | nil
12
+
13
+ # The string to the right of the last successful match.
14
+ $': String | nil
15
+
16
+ # The same as ARGV.
17
+ $*: Array[String]
18
+
19
+ # The highest group matched by the last successful match.
20
+ $+: String | nil
21
+
22
+ # The output field separator for Kernel#print and Array#join. Non-nil $, will be deprecated.
23
+ $,: String | nil
24
+
25
+ # The input record separator, newline by default.
26
+ $-0: String | nil
27
+
28
+ # The default separator for String#split. Non-nil $; will be deprecated.
29
+ $-F: Regexp | String | nil
30
+
31
+ # Load path for searching Ruby scripts and extension libraries used
32
+ # by Kernel#load and Kernel#require.
33
+ # Has a singleton method <code>$LOAD_PATH.resolve_feature_path(feature)</code>
34
+ # that returns [+:rb+ or +:so+, path], which resolves the feature to
35
+ # the path the original Kernel#require method would load.
36
+ $-I: Array[String]
37
+
38
+ $-W: 0 | 1 | 2
39
+
40
+ # True if option <tt>-a</tt> is set. Read-only variable.
41
+ $-a: bool
42
+
43
+ # The debug flag, which is set by the <tt>-d</tt> switch. Enabling debug
44
+ # output prints each exception raised to $stderr (but not its
45
+ # backtrace). Setting this to a true value enables debug output as
46
+ # if <tt>-d</tt> were given on the command line. Setting this to a false
47
+ # value disables debug output.
48
+ $-d: bool
49
+
50
+ # In in-place-edit mode, this variable holds the extension, otherwise +nil+.
51
+ $-i: bool
52
+
53
+ # True if option <tt>-l</tt> is set. Read-only variable.
54
+ $-l: bool
55
+
56
+ # True if option <tt>-p</tt> is set. Read-only variable.
57
+ $-p: bool
58
+
59
+ # The verbose flag, which is set by the <tt>-w</tt> or <tt>-v</tt> switch.
60
+ # Setting this to a true value enables warnings as if <tt>-w</tt> or <tt>-v</tt> were given
61
+ # on the command line. Setting this to +nil+ disables warnings,
62
+ # including from Kernel#warn.
63
+ $-v: bool | nil
64
+
65
+ # The verbose flag, which is set by the <tt>-w</tt> or <tt>-v</tt> switch.
66
+ # Setting this to a true value enables warnings as if <tt>-w</tt> or <tt>-v</tt> were given
67
+ # on the command line. Setting this to +nil+ disables warnings,
68
+ # including from Kernel#warn.
69
+ $-w: bool | nil
70
+
71
+ # The current input line number of the last file that was read.
72
+ $.: Integer
73
+
74
+ # The input record separator, newline by default. Aliased to $-0.
75
+ $/: String | nil
76
+
77
+ # The same as $!.backtrace.
78
+ $0: String
79
+
80
+ # The Nth group of the last successful match. May be > 1.
81
+ $1: String | nil
82
+
83
+ # The Nth group of the last successful match. May be > 1.
84
+ $2: String | nil
85
+
86
+ # The Nth group of the last successful match. May be > 1.
87
+ $3: String | nil
88
+
89
+ # The Nth group of the last successful match. May be > 1.
90
+ $4: String | nil
91
+
92
+ # The Nth group of the last successful match. May be > 1.
93
+ $5: String | nil
94
+
95
+ # The Nth group of the last successful match. May be > 1.
96
+ $6: String | nil
97
+
98
+ # The Nth group of the last successful match. May be > 1.
99
+ $7: String | nil
100
+
101
+ # The Nth group of the last successful match. May be > 1.
102
+ $8: String | nil
103
+
104
+ # The Nth group of the last successful match. May be > 1.
105
+ $9: String | nil
106
+
107
+ # Load path for searching Ruby scripts and extension libraries used
108
+ # by Kernel#load and Kernel#require.
109
+ # Has a singleton method <code>$LOAD_PATH.resolve_feature_path(feature)</code>
110
+ # that returns [+:rb+ or +:so+, path], which resolves the feature to
111
+ # the path the original Kernel#require method would load.
112
+ $:: Array[String]
113
+
114
+ # The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F.
115
+ $;: Regexp | String | nil
116
+
117
+ # The same as ARGF.
118
+ $<: IO
119
+
120
+ # This variable is no longer effective. Deprecated.
121
+ $=: bool
122
+
123
+ # The default output stream for Kernel#print and Kernel#printf. $stdout by default.
124
+ $>: IO
125
+
126
+ # The status of the last executed child process (thread-local).
127
+ $?: Process::Status | nil
128
+
129
+ # The same as <code>$!.backtrace</code>.
130
+ $@: Array[String] | nil
131
+
132
+ # The debug flag, which is set by the <tt>-d</tt> switch. Enabling debug
133
+ # output prints each exception raised to $stderr (but not its
134
+ # backtrace). Setting this to a true value enables debug output as
135
+ # if <tt>-d</tt> were given on the command line. Setting this to a false
136
+ # value disables debug output. Aliased to $-d.
137
+ $DEBUG: bool
138
+
139
+ # Current input filename from ARGF. Same as ARGF.filename.
140
+ $FILENAME: String
141
+
142
+ # The array contains the module names loaded by require.
143
+ $LOADED_FEATURES: Array[String]
144
+
145
+ # Load path for searching Ruby scripts and extension libraries used
146
+ # by Kernel#load and Kernel#require. Aliased to $: and $-I.
147
+ # Has a singleton method <code>$LOAD_PATH.resolve_feature_path(feature)</code>
148
+ # that returns [+:rb+ or +:so+, path], which resolves the feature to
149
+ # the path the original Kernel#require method would load.
150
+ $LOAD_PATH: Array[String]
151
+
152
+ # The same as $!.backtrace.
153
+ $PROGRAM_NAME: String
154
+
155
+ # The verbose flag, which is set by the <tt>-w</tt> or <tt>-v</tt> switch.
156
+ # Setting this to a true value enables warnings as if <tt>-w</tt> or <tt>-v</tt> were given
157
+ # on the command line. Setting this to +nil+ disables warnings,
158
+ # including from Kernel#warn. Aliased to $-v and $-w.
159
+ $VERBOSE: bool | nil
160
+
161
+ # The output record separator for Kernel#print and IO#write. Default is +nil+.
162
+ $\: String | nil
163
+
164
+ # The last input line of string by gets or readline.
165
+ $_: String | nil
166
+
167
+ # The string to the left of the last successful match.
168
+ $`: String | nil
169
+
170
+ # The current standard error output.
171
+ $stderr: IO
172
+
173
+ # The current standard input.
174
+ $stdin: IO
175
+
176
+ # The current standard output.
177
+ $stdout: IO
178
+
179
+ # The information about the last match in the current scope (thread-local and frame-local).
180
+ $~: MatchData | nil
data/core/hash.rbs CHANGED
@@ -493,8 +493,8 @@ class Hash[unchecked out K, unchecked out V] < Object
493
493
  # h.fetch_values("cow", "bird") # raises KeyError
494
494
  # h.fetch_values("cow", "bird") { |k| k.upcase } #=> ["bovine", "BIRD"]
495
495
  #
496
- def fetch_values: (*K) -> Array[V]
497
- | [X] (*K) { (K) -> X } -> (V | X)
496
+ def fetch_values: (*K) -> ::Array[V]
497
+ | [X] (*K) { (K) -> X } -> ::Array[V | X]
498
498
 
499
499
  # Returns a new hash consisting of entries for which the block returns true.
500
500
  #
@@ -906,8 +906,8 @@ class Hash[unchecked out K, unchecked out V] < Object
906
906
  #
907
907
  # If no block is given, an enumerator is returned instead.
908
908
  #
909
- def transform_keys!: () -> Enumerator[K, Hash[untyped, V]]
910
- | () { (K) -> K } -> Hash[K, V]
909
+ def transform_keys!: () -> Enumerator[K, self]
910
+ | () { (K) -> K } -> self
911
911
 
912
912
  # Returns a new hash with the results of running the block once for every value.
913
913
  # This method does not change the keys.
@@ -920,7 +920,7 @@ class Hash[unchecked out K, unchecked out V] < Object
920
920
  #
921
921
  # If no block is given, an enumerator is returned instead.
922
922
  #
923
- def transform_values: () -> Enumerator[K, Hash[K, untyped]]
923
+ def transform_values: () -> Enumerator[V, Hash[K, untyped]]
924
924
  | [A] () { (V) -> A } -> Hash[K, A]
925
925
 
926
926
  # Invokes the given block once for each value in *hsh*, replacing it with the
@@ -935,8 +935,8 @@ class Hash[unchecked out K, unchecked out V] < Object
935
935
  #
936
936
  # If no block is given, an enumerator is returned instead.
937
937
  #
938
- def transform_values!: () -> Enumerator[K, Hash[K, untyped]]
939
- | () { (V) -> V } -> Hash[K, V]
938
+ def transform_values!: () -> Enumerator[V, self]
939
+ | () { (V) -> V } -> self
940
940
 
941
941
  # Adds the contents of the given hashes to the receiver.
942
942
  #