rbs 3.10.2 → 4.0.0.dev.1
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/.github/workflows/comments.yml +2 -2
- data/.github/workflows/ruby.yml +24 -34
- data/.github/workflows/typecheck.yml +3 -1
- data/.github/workflows/windows.yml +2 -2
- data/.gitignore +0 -4
- data/CHANGELOG.md +0 -107
- data/README.md +1 -38
- data/Rakefile +20 -142
- data/Steepfile +1 -0
- data/config.yml +43 -1
- data/core/array.rbs +46 -96
- data/core/comparable.rbs +6 -13
- data/core/complex.rbs +25 -40
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +9 -6
- data/core/enumerable.rbs +3 -90
- data/core/enumerator.rbs +1 -43
- data/core/errno.rbs +0 -8
- data/core/errors.rbs +1 -28
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +20 -29
- data/core/file.rbs +19 -49
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +33 -224
- data/core/gc.rbs +281 -417
- data/core/hash.rbs +727 -1023
- data/core/integer.rbs +63 -104
- data/core/io/buffer.rbs +10 -21
- data/core/io/wait.rbs +33 -11
- data/core/io.rbs +12 -14
- data/core/kernel.rbs +51 -61
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +3 -42
- data/core/method.rbs +25 -63
- data/core/module.rbs +23 -101
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +17 -25
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +15 -21
- data/core/proc.rbs +24 -30
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +509 -361
- data/core/range.rbs +8 -7
- data/core/rational.rbs +34 -56
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +2 -4
- data/core/regexp.rbs +20 -25
- data/core/ruby_vm.rbs +4 -6
- data/core/rubygems/errors.rbs +70 -3
- data/core/rubygems/rubygems.rbs +79 -11
- data/core/rubygems/version.rbs +3 -2
- data/core/set.rbs +359 -488
- data/core/signal.rbs +14 -24
- data/core/string.rbs +1236 -3165
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +11 -17
- data/core/thread.rbs +33 -95
- data/core/time.rbs +9 -35
- data/core/trace_point.rbs +4 -7
- data/core/unbound_method.rbs +6 -14
- data/docs/collection.md +2 -2
- data/docs/gem.md +1 -0
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1077 -944
- data/ext/rbs_extension/ast_translation.h +0 -7
- data/ext/rbs_extension/class_constants.c +83 -71
- data/ext/rbs_extension/class_constants.h +7 -4
- data/ext/rbs_extension/extconf.rb +2 -24
- data/ext/rbs_extension/legacy_location.c +172 -173
- data/ext/rbs_extension/legacy_location.h +3 -8
- data/ext/rbs_extension/main.c +289 -239
- data/ext/rbs_extension/rbs_extension.h +0 -3
- data/ext/rbs_extension/rbs_string_bridging.h +0 -4
- data/include/rbs/ast.h +98 -37
- data/include/rbs/defines.h +12 -38
- data/include/rbs/lexer.h +114 -126
- data/include/rbs/location.h +14 -14
- data/include/rbs/parser.h +37 -21
- data/include/rbs/string.h +5 -3
- data/include/rbs/util/rbs_allocator.h +19 -40
- data/include/rbs/util/rbs_assert.h +1 -12
- data/include/rbs/util/rbs_constant_pool.h +3 -3
- data/include/rbs/util/rbs_encoding.h +1 -3
- data/include/rbs/util/rbs_unescape.h +1 -2
- data/lib/rbs/ast/ruby/annotations.rb +119 -0
- data/lib/rbs/ast/ruby/comment_block.rb +221 -0
- data/lib/rbs/ast/ruby/declarations.rb +86 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +213 -0
- data/lib/rbs/buffer.rb +104 -24
- data/lib/rbs/cli/validate.rb +40 -35
- data/lib/rbs/cli.rb +5 -6
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -8
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
- data/lib/rbs/definition_builder/method_builder.rb +45 -30
- data/lib/rbs/definition_builder.rb +44 -9
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +244 -218
- data/lib/rbs/environment_loader.rb +8 -2
- data/lib/rbs/errors.rb +5 -4
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +206 -0
- data/lib/rbs/location_aux.rb +35 -3
- data/lib/rbs/parser_aux.rb +11 -6
- data/lib/rbs/prototype/runtime.rb +2 -2
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +38 -124
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +5 -6
- data/lib/rbs/test/type_check.rb +0 -14
- data/lib/rbs/types.rb +1 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +13 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +1 -0
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +110 -0
- data/sig/ast/ruby/comment_block.rbs +119 -0
- data/sig/ast/ruby/declarations.rbs +60 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +72 -0
- data/sig/buffer.rbs +63 -5
- data/sig/definition.rbs +1 -0
- data/sig/definition_builder.rbs +1 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +28 -133
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +87 -0
- data/sig/location.rbs +32 -7
- data/sig/manifest.yaml +1 -0
- data/sig/method_builder.rbs +7 -4
- data/sig/parser.rbs +16 -20
- data/sig/resolver/type_name_resolver.rbs +7 -38
- data/sig/source.rbs +48 -0
- data/sig/types.rbs +1 -4
- data/src/ast.c +290 -201
- data/src/lexer.c +2813 -2902
- data/src/lexer.re +4 -0
- data/src/lexstate.c +155 -169
- data/src/location.c +40 -40
- data/src/parser.c +2665 -2433
- data/src/string.c +48 -0
- data/src/util/rbs_allocator.c +76 -92
- data/src/util/rbs_assert.c +10 -10
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +15 -13
- data/src/util/rbs_encoding.c +4062 -20097
- data/src/util/rbs_unescape.c +48 -85
- data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
- data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
- data/stdlib/cgi/0/core.rbs +393 -9
- data/stdlib/cgi/0/manifest.yaml +0 -1
- data/stdlib/coverage/0/coverage.rbs +1 -3
- data/stdlib/date/0/date.rbs +59 -67
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +7 -10
- data/stdlib/erb/0/erb.rbs +347 -737
- data/stdlib/fileutils/0/fileutils.rbs +13 -18
- data/stdlib/forwardable/0/forwardable.rbs +0 -3
- data/stdlib/json/0/json.rbs +48 -68
- data/stdlib/net-http/0/net-http.rbs +0 -3
- data/stdlib/objspace/0/objspace.rbs +4 -9
- data/stdlib/open-uri/0/open-uri.rbs +0 -40
- data/stdlib/openssl/0/openssl.rbs +228 -331
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/pathname/0/pathname.rbs +1380 -10
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +68 -25
- data/stdlib/ripper/0/ripper.rbs +2 -5
- data/stdlib/singleton/0/singleton.rbs +0 -3
- data/stdlib/socket/0/socket.rbs +1 -13
- data/stdlib/socket/0/tcp_socket.rbs +2 -10
- data/stdlib/stringio/0/stringio.rbs +85 -1176
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +7 -63
- data/stdlib/tsort/0/cyclic.rbs +0 -3
- data/stdlib/uri/0/common.rbs +2 -11
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +16 -17
- data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
- data/stdlib/zlib/0/zstream.rbs +0 -1
- metadata +39 -12
- data/.clang-format +0 -74
- data/.clangd +0 -2
- data/.github/workflows/c-check.yml +0 -54
- data/core/pathname.rbs +0 -1272
- data/core/ruby.rbs +0 -53
- data/docs/aliases.md +0 -79
- data/docs/encoding.md +0 -56
- data/ext/rbs_extension/compat.h +0 -10
- data/stdlib/cgi-escape/0/escape.rbs +0 -171
data/core/enumerable.rbs
CHANGED
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
# by the block.
|
|
115
115
|
# * #grep: Returns elements selected by a given object or objects returned by
|
|
116
116
|
# a given block.
|
|
117
|
-
# * #grep_v: Returns elements
|
|
118
|
-
#
|
|
117
|
+
# * #grep_v: Returns elements selected by a given object or objects returned
|
|
118
|
+
# by a given block.
|
|
119
119
|
# * #inject (aliased as #reduce): Returns the object formed by combining all
|
|
120
120
|
# elements.
|
|
121
121
|
# * #sum: Returns the sum of the elements, using method `+`.
|
|
@@ -191,82 +191,6 @@
|
|
|
191
191
|
# usage would not make sense, and so it is not shown. Example: #tally would
|
|
192
192
|
# find exactly one of each Hash entry.
|
|
193
193
|
#
|
|
194
|
-
# ## Extended Methods
|
|
195
|
-
#
|
|
196
|
-
# A Enumerable class may define extended methods. This section describes the
|
|
197
|
-
# standard behavior of extension methods for reference purposes.
|
|
198
|
-
#
|
|
199
|
-
# ### #size
|
|
200
|
-
#
|
|
201
|
-
# Enumerator has a #size method. It uses the size function argument passed to
|
|
202
|
-
# `Enumerator.new`.
|
|
203
|
-
#
|
|
204
|
-
# e = Enumerator.new(-> { 3 }) {|y| p y; y.yield :a; y.yield :b; y.yield :c; :z }
|
|
205
|
-
# p e.size #=> 3
|
|
206
|
-
# p e.next #=> :a
|
|
207
|
-
# p e.next #=> :b
|
|
208
|
-
# p e.next #=> :c
|
|
209
|
-
# begin
|
|
210
|
-
# e.next
|
|
211
|
-
# rescue StopIteration
|
|
212
|
-
# p $!.result #=> :z
|
|
213
|
-
# end
|
|
214
|
-
#
|
|
215
|
-
# The result of the size function should represent the number of iterations
|
|
216
|
-
# (i.e., the number of times Enumerator::Yielder#yield is called). In the above
|
|
217
|
-
# example, the block calls #yield three times, and the size function, +-> { 3
|
|
218
|
-
# }+, returns 3 accordingly. The result of the size function can be an integer,
|
|
219
|
-
# `Float::INFINITY`, or `nil`. An integer means the exact number of times #yield
|
|
220
|
-
# will be called, as shown above. `Float::INFINITY` indicates an infinite number
|
|
221
|
-
# of #yield calls. `nil` means the number of #yield calls is difficult or
|
|
222
|
-
# impossible to determine.
|
|
223
|
-
#
|
|
224
|
-
# Many iteration methods return an Enumerator object with an appropriate size
|
|
225
|
-
# function if no block is given.
|
|
226
|
-
#
|
|
227
|
-
# Examples:
|
|
228
|
-
#
|
|
229
|
-
# ["a", "b", "c"].each.size #=> 3
|
|
230
|
-
# {a: "x", b: "y", c: "z"}.each.size #=> 3
|
|
231
|
-
# (0..20).to_a.permutation.size #=> 51090942171709440000
|
|
232
|
-
# loop.size #=> Float::INFINITY
|
|
233
|
-
# (1..100).drop_while.size #=> nil # size depends on the block's behavior
|
|
234
|
-
# STDIN.each.size #=> nil # cannot be computed without consuming input
|
|
235
|
-
# File.open("/etc/resolv.conf").each.size #=> nil # cannot be computed without reading the file
|
|
236
|
-
#
|
|
237
|
-
# The behavior of #size for Range-based enumerators depends on the #begin
|
|
238
|
-
# element:
|
|
239
|
-
#
|
|
240
|
-
# * If the #begin element is an Integer, the #size method returns an Integer
|
|
241
|
-
# or `Float::INFINITY`.
|
|
242
|
-
# * If the #begin element is an object with a #succ method (other than
|
|
243
|
-
# Integer), #size returns `nil`. (Computing the size would require
|
|
244
|
-
# repeatedly calling #succ, which may be too slow.)
|
|
245
|
-
# * If the #begin element does not have a #succ method, #size raises a
|
|
246
|
-
# TypeError.
|
|
247
|
-
#
|
|
248
|
-
# Examples:
|
|
249
|
-
#
|
|
250
|
-
# (10..42).each.size #=> 33
|
|
251
|
-
# (10..42.9).each.size #=> 33 (the #end element may be a non-integer numeric)
|
|
252
|
-
# (10..).each.size #=> Float::INFINITY
|
|
253
|
-
# ("a".."z").each.size #=> nil
|
|
254
|
-
# ("a"..).each.size #=> nil
|
|
255
|
-
# (1.0..9.0).each.size # raises TypeError (Float does not have #succ)
|
|
256
|
-
# (..10).each.size # raises TypeError (beginless range has nil as its #begin)
|
|
257
|
-
#
|
|
258
|
-
# The Enumerable module itself does not define a #size method. A class that
|
|
259
|
-
# includes Enumerable may define its own #size method. It is recommended that
|
|
260
|
-
# such a #size method be consistent with Enumerator#size.
|
|
261
|
-
#
|
|
262
|
-
# Array and Hash implement #size and return values consistent with
|
|
263
|
-
# Enumerator#size. IO and Dir do not define #size, which is also consistent
|
|
264
|
-
# because the corresponding enumerator's size function returns `nil`.
|
|
265
|
-
#
|
|
266
|
-
# However, it is not strictly required for a class's #size method to match
|
|
267
|
-
# Enumerator#size. For example, File#size returns the number of bytes in the
|
|
268
|
-
# file, not the number of lines.
|
|
269
|
-
#
|
|
270
194
|
module Enumerable[unchecked out Elem] : _Each[Elem]
|
|
271
195
|
# <!--
|
|
272
196
|
# rdoc-file=enum.c
|
|
@@ -514,17 +438,6 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
|
|
|
514
438
|
#
|
|
515
439
|
# With no block given, returns an Enumerator.
|
|
516
440
|
#
|
|
517
|
-
# e = (1..4).drop_while
|
|
518
|
-
# p e #=> #<Enumerator: 1..4:drop_while>
|
|
519
|
-
# i = e.next; p i; e.feed(i < 3) #=> 1
|
|
520
|
-
# i = e.next; p i; e.feed(i < 3) #=> 2
|
|
521
|
-
# i = e.next; p i; e.feed(i < 3) #=> 3
|
|
522
|
-
# begin
|
|
523
|
-
# e.next
|
|
524
|
-
# rescue StopIteration
|
|
525
|
-
# p $!.result #=> [3, 4]
|
|
526
|
-
# end
|
|
527
|
-
#
|
|
528
441
|
def drop_while: () { (Elem) -> boolish } -> ::Array[Elem]
|
|
529
442
|
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
530
443
|
|
|
@@ -2127,7 +2040,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
|
|
|
2127
2040
|
# ["F", 6860]
|
|
2128
2041
|
#
|
|
2129
2042
|
# You can use the special symbol `:_alone` to force an element into its own
|
|
2130
|
-
# separate
|
|
2043
|
+
# separate chuck:
|
|
2131
2044
|
#
|
|
2132
2045
|
# a = [0, 0, 1, 1]
|
|
2133
2046
|
# e = a.chunk{|i| i.even? ? :_alone : true }
|
data/core/enumerator.rbs
CHANGED
|
@@ -137,7 +137,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
|
|
|
137
137
|
|
|
138
138
|
# <!--
|
|
139
139
|
# rdoc-file=enumerator.c
|
|
140
|
-
# - Enumerator.produce(initial = nil
|
|
140
|
+
# - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
|
|
141
141
|
# -->
|
|
142
142
|
# Creates an infinite enumerator from any block, just called over and over. The
|
|
143
143
|
# result of the previous iteration is passed to the next one. If `initial` is
|
|
@@ -169,29 +169,6 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
|
|
|
169
169
|
# Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
|
|
170
170
|
# # => ["7", "+", "38", "/", "6"]
|
|
171
171
|
#
|
|
172
|
-
# The optional `size` keyword argument specifies the size of the enumerator,
|
|
173
|
-
# which can be retrieved by Enumerator#size. It can be an integer,
|
|
174
|
-
# `Float::INFINITY`, a callable object (such as a lambda), or `nil` to indicate
|
|
175
|
-
# unknown size. When not specified, the size defaults to `Float::INFINITY`.
|
|
176
|
-
#
|
|
177
|
-
# # Infinite enumerator
|
|
178
|
-
# enum = Enumerator.produce(1, size: Float::INFINITY, &:succ)
|
|
179
|
-
# enum.size # => Float::INFINITY
|
|
180
|
-
#
|
|
181
|
-
# # Finite enumerator with known/computable size
|
|
182
|
-
# abs_dir = File.expand_path("./baz") # => "/foo/bar/baz"
|
|
183
|
-
# traverser = Enumerator.produce(abs_dir, size: -> { abs_dir.count("/") + 1 }) {
|
|
184
|
-
# raise StopIteration if it == "/"
|
|
185
|
-
# File.dirname(it)
|
|
186
|
-
# }
|
|
187
|
-
# traverser.size # => 4
|
|
188
|
-
#
|
|
189
|
-
# # Finite enumerator with unknown size
|
|
190
|
-
# calendar = Enumerator.produce(Date.today, size: nil) {
|
|
191
|
-
# it.monday? ? raise(StopIteration) : it + 1
|
|
192
|
-
# }
|
|
193
|
-
# calendar.size # => nil
|
|
194
|
-
#
|
|
195
172
|
def self.produce: [T] () { (T? prev) -> T } -> Enumerator[T, bot]
|
|
196
173
|
| [T] (T initial) { (T prev) -> T } -> Enumerator[T, bot]
|
|
197
174
|
|
|
@@ -469,25 +446,6 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
|
|
|
469
446
|
# loop.size # => Float::INFINITY
|
|
470
447
|
# (1..100).drop_while.size # => nil
|
|
471
448
|
#
|
|
472
|
-
# Note that enumerator size might be inaccurate, and should be rather treated as
|
|
473
|
-
# a hint. For example, there is no check that the size provided to ::new is
|
|
474
|
-
# accurate:
|
|
475
|
-
#
|
|
476
|
-
# e = Enumerator.new(5) { |y| 2.times { y << it} }
|
|
477
|
-
# e.size # => 5
|
|
478
|
-
# e.to_a.size # => 2
|
|
479
|
-
#
|
|
480
|
-
# Another example is an enumerator created by ::produce without a `size`
|
|
481
|
-
# argument. Such enumerators return `Infinity` for size, but this is inaccurate
|
|
482
|
-
# if the passed block raises StopIteration:
|
|
483
|
-
#
|
|
484
|
-
# e = Enumerator.produce(1) { it + 1 }
|
|
485
|
-
# e.size # => Infinity
|
|
486
|
-
#
|
|
487
|
-
# e = Enumerator.produce(1) { it > 3 ? raise(StopIteration) : it + 1 }
|
|
488
|
-
# e.size # => Infinity
|
|
489
|
-
# e.to_a.size # => 4
|
|
490
|
-
#
|
|
491
449
|
def size: () -> (Integer | Float)?
|
|
492
450
|
|
|
493
451
|
# <!--
|
data/core/errno.rbs
CHANGED
|
@@ -38,14 +38,6 @@
|
|
|
38
38
|
# Errno::ENOENT::Errno # => 2
|
|
39
39
|
# Errno::ENOTCAPABLE::Errno # => 0
|
|
40
40
|
#
|
|
41
|
-
# Each class in Errno can be created with optional messages:
|
|
42
|
-
#
|
|
43
|
-
# Errno::EPIPE.new # => #<Errno::EPIPE: Broken pipe>
|
|
44
|
-
# Errno::EPIPE.new("foo") # => #<Errno::EPIPE: Broken pipe - foo>
|
|
45
|
-
# Errno::EPIPE.new("foo", "here") # => #<Errno::EPIPE: Broken pipe @ here - foo>
|
|
46
|
-
#
|
|
47
|
-
# See SystemCallError.new.
|
|
48
|
-
#
|
|
49
41
|
module Errno
|
|
50
42
|
class NOERROR < SystemCallError
|
|
51
43
|
Errno: 0
|
data/core/errors.rbs
CHANGED
|
@@ -302,15 +302,9 @@ class NameError[T] < StandardError
|
|
|
302
302
|
def receiver: () -> T?
|
|
303
303
|
end
|
|
304
304
|
|
|
305
|
-
# <!-- rdoc-file=error.c -->
|
|
306
|
-
# Raised when matching pattern not found.
|
|
307
|
-
#
|
|
308
305
|
class NoMatchingPatternError < StandardError
|
|
309
306
|
end
|
|
310
307
|
|
|
311
|
-
# <!-- rdoc-file=error.c -->
|
|
312
|
-
# Raised when matching key not found.
|
|
313
|
-
#
|
|
314
308
|
class NoMatchingPatternKeyError[M, K] < NoMatchingPatternError
|
|
315
309
|
# <!--
|
|
316
310
|
# rdoc-file=error.c
|
|
@@ -594,34 +588,13 @@ end
|
|
|
594
588
|
class SystemCallError < StandardError
|
|
595
589
|
# <!--
|
|
596
590
|
# rdoc-file=error.c
|
|
597
|
-
# - SystemCallError.new(msg, errno
|
|
591
|
+
# - SystemCallError.new(msg, errno) -> system_call_error_subclass
|
|
598
592
|
# -->
|
|
599
593
|
# If *errno* corresponds to a known system error code, constructs the
|
|
600
594
|
# appropriate Errno class for that error, otherwise constructs a generic
|
|
601
595
|
# SystemCallError object. The error number is subsequently available via the
|
|
602
596
|
# #errno method.
|
|
603
597
|
#
|
|
604
|
-
# If only numeric object is given, it is treated as an Integer *errno*, and
|
|
605
|
-
# *msg* is omitted, otherwise the first argument *msg* is used as the additional
|
|
606
|
-
# error message.
|
|
607
|
-
#
|
|
608
|
-
# SystemCallError.new(Errno::EPIPE::Errno)
|
|
609
|
-
# #=> #<Errno::EPIPE: Broken pipe>
|
|
610
|
-
#
|
|
611
|
-
# SystemCallError.new("foo")
|
|
612
|
-
# #=> #<SystemCallError: unknown error - foo>
|
|
613
|
-
#
|
|
614
|
-
# SystemCallError.new("foo", Errno::EPIPE::Errno)
|
|
615
|
-
# #=> #<Errno::EPIPE: Broken pipe - foo>
|
|
616
|
-
#
|
|
617
|
-
# If *func* is not `nil`, it is appended to the message with "` @ `".
|
|
618
|
-
#
|
|
619
|
-
# SystemCallError.new("foo", Errno::EPIPE::Errno, "here")
|
|
620
|
-
# #=> #<Errno::EPIPE: Broken pipe @ here - foo>
|
|
621
|
-
#
|
|
622
|
-
# A subclass of SystemCallError can also be instantiated via the `new` method of
|
|
623
|
-
# the subclass. See Errno.
|
|
624
|
-
#
|
|
625
598
|
def initialize: (string msg, Integer errno) -> void
|
|
626
599
|
|
|
627
600
|
# <!--
|
data/core/exception.rbs
CHANGED
|
@@ -118,7 +118,7 @@ class Exception
|
|
|
118
118
|
# # String
|
|
119
119
|
# end
|
|
120
120
|
#
|
|
121
|
-
# The value returned by this method
|
|
121
|
+
# The value returned by this method migth be adjusted when raising (see
|
|
122
122
|
# Kernel#raise), or during intermediate handling by #set_backtrace.
|
|
123
123
|
#
|
|
124
124
|
# See also #backtrace_locations that provide the same value, as structured
|
|
@@ -447,7 +447,7 @@ class Exception
|
|
|
447
447
|
# * If the value of keyword `order` is `:top` (the default), lists the
|
|
448
448
|
# error message and the innermost backtrace entry first.
|
|
449
449
|
# * If the value of keyword `order` is `:bottom`, lists the error message
|
|
450
|
-
# the innermost entry last.
|
|
450
|
+
# the the innermost entry last.
|
|
451
451
|
#
|
|
452
452
|
# Example:
|
|
453
453
|
#
|
data/core/fiber.rbs
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
# ## Non-blocking Fibers
|
|
59
59
|
#
|
|
60
60
|
# The concept of *non-blocking fiber* was introduced in Ruby 3.0. A non-blocking
|
|
61
|
-
# fiber, when reaching
|
|
61
|
+
# fiber, when reaching a operation that would normally block the fiber (like
|
|
62
62
|
# `sleep`, or wait for another process or I/O) will yield control to other
|
|
63
63
|
# fibers and allow the *scheduler* to handle blocking and waking up (resuming)
|
|
64
64
|
# this fiber when it can proceed.
|
|
@@ -82,8 +82,7 @@ class Fiber < Object
|
|
|
82
82
|
# -->
|
|
83
83
|
# Returns the value of the fiber storage variable identified by `key`.
|
|
84
84
|
#
|
|
85
|
-
# The `key` must be a symbol, and the value is set by Fiber#[]= or
|
|
86
|
-
# Fiber#storage.
|
|
85
|
+
# The `key` must be a symbol, and the value is set by Fiber#[]= or Fiber#store.
|
|
87
86
|
#
|
|
88
87
|
# See also Fiber::[]=.
|
|
89
88
|
#
|
|
@@ -393,38 +392,30 @@ class Fiber < Object
|
|
|
393
392
|
|
|
394
393
|
# <!--
|
|
395
394
|
# rdoc-file=cont.c
|
|
396
|
-
# - raise
|
|
397
|
-
# - raise(
|
|
395
|
+
# - fiber.raise -> obj
|
|
396
|
+
# - fiber.raise(string) -> obj
|
|
397
|
+
# - fiber.raise(exception [, string [, array]]) -> obj
|
|
398
398
|
# -->
|
|
399
399
|
# Raises an exception in the fiber at the point at which the last `Fiber.yield`
|
|
400
|
-
# was called.
|
|
401
|
-
#
|
|
402
|
-
#
|
|
403
|
-
#
|
|
404
|
-
#
|
|
405
|
-
#
|
|
406
|
-
#
|
|
407
|
-
#
|
|
408
|
-
#
|
|
409
|
-
#
|
|
410
|
-
#
|
|
411
|
-
#
|
|
412
|
-
#
|
|
413
|
-
# Before the first yield
|
|
414
|
-
# 1
|
|
415
|
-
# t.rb:8:in 'Fiber.yield': Gotcha (RuntimeError)
|
|
416
|
-
# from t.rb:8:in 'block in <main>'
|
|
417
|
-
#
|
|
418
|
-
# If the fiber has not been started or has already run to completion, raises
|
|
419
|
-
# `FiberError`. If the fiber is yielding, it is resumed. If it is transferring,
|
|
420
|
-
# it is transferred into. But if it is resuming, raises `FiberError`.
|
|
400
|
+
# was called. If the fiber has not been started or has already run to
|
|
401
|
+
# completion, raises `FiberError`. If the fiber is yielding, it is resumed. If
|
|
402
|
+
# it is transferring, it is transferred into. But if it is resuming, raises
|
|
403
|
+
# `FiberError`.
|
|
404
|
+
#
|
|
405
|
+
# With no arguments, raises a `RuntimeError`. With a single `String` argument,
|
|
406
|
+
# raises a `RuntimeError` with the string as a message. Otherwise, the first
|
|
407
|
+
# parameter should be the name of an `Exception` class (or an object that
|
|
408
|
+
# returns an `Exception` object when sent an `exception` message). The optional
|
|
409
|
+
# second parameter sets the message associated with the exception, and the third
|
|
410
|
+
# parameter is an array of callback information. Exceptions are caught by the
|
|
411
|
+
# `rescue` clause of `begin...end` blocks.
|
|
421
412
|
#
|
|
422
413
|
# Raises `FiberError` if called on a Fiber belonging to another `Thread`.
|
|
423
414
|
#
|
|
424
|
-
# See Kernel#raise for more information
|
|
415
|
+
# See Kernel#raise for more information.
|
|
425
416
|
#
|
|
426
|
-
def raise: (?string msg
|
|
427
|
-
| (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace
|
|
417
|
+
def raise: (?string msg) -> untyped
|
|
418
|
+
| (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace) -> untyped
|
|
428
419
|
|
|
429
420
|
# <!--
|
|
430
421
|
# rdoc-file=cont.c
|
data/core/file.rbs
CHANGED
|
@@ -1414,7 +1414,7 @@ class File < IO
|
|
|
1414
1414
|
# rdoc-file=file.c
|
|
1415
1415
|
# - File.owned?(file_name) -> true or false
|
|
1416
1416
|
# -->
|
|
1417
|
-
# Returns `true` if the named file exists and the effective
|
|
1417
|
+
# Returns `true` if the named file exists and the effective used id of the
|
|
1418
1418
|
# calling process is the owner of the file.
|
|
1419
1419
|
#
|
|
1420
1420
|
# *file_name* can be an IO object.
|
|
@@ -1427,25 +1427,8 @@ class File < IO
|
|
|
1427
1427
|
# -->
|
|
1428
1428
|
# Returns the string representation of the path
|
|
1429
1429
|
#
|
|
1430
|
-
#
|
|
1431
|
-
#
|
|
1432
|
-
#
|
|
1433
|
-
# If `path` is not a String:
|
|
1434
|
-
#
|
|
1435
|
-
# 1. If it has the `to_path` method, that method will be called to coerce to a
|
|
1436
|
-
# String.
|
|
1437
|
-
#
|
|
1438
|
-
# 2. Otherwise, or if the coerced result is not a String too, the standard
|
|
1439
|
-
# coersion using `to_str` method will take place on that object. (See also
|
|
1440
|
-
# String.try_convert)
|
|
1441
|
-
#
|
|
1442
|
-
# The coerced string must satisfy the following conditions:
|
|
1443
|
-
#
|
|
1444
|
-
# 1. It must be in an ASCII-compatible encoding; otherwise, an
|
|
1445
|
-
# Encoding::CompatibilityError is raised.
|
|
1446
|
-
#
|
|
1447
|
-
# 2. It must not contain the NUL character (`\0`); otherwise, an ArgumentError
|
|
1448
|
-
# is raised.
|
|
1430
|
+
# File.path(File::NULL) #=> "/dev/null"
|
|
1431
|
+
# File.path(Pathname.new("/tmp")) #=> "/tmp"
|
|
1449
1432
|
#
|
|
1450
1433
|
def self.path: (string | _ToPath path) -> String
|
|
1451
1434
|
|
|
@@ -1839,12 +1822,12 @@ class File < IO
|
|
|
1839
1822
|
# Returns `false` if `File::LOCK_NB` is specified and the operation would have
|
|
1840
1823
|
# blocked;
|
|
1841
1824
|
# otherwise returns `0`.
|
|
1842
|
-
# Constant | Lock |
|
|
1843
|
-
#
|
|
1844
|
-
#
|
|
1845
|
-
#
|
|
1846
|
-
#
|
|
1847
|
-
#
|
|
1825
|
+
# Constant | Lock | Effect
|
|
1826
|
+
# ---------------|------------|--------------------------------------------------------------------------------------------------------------
|
|
1827
|
+
# +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
|
|
1828
|
+
# +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <tt>|</tt>.
|
|
1829
|
+
# +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
|
|
1830
|
+
# +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
|
|
1848
1831
|
# Example:
|
|
1849
1832
|
# # Update a counter using an exclusive lock.
|
|
1850
1833
|
# # Don't use File::WRONLY because it truncates the file.
|
|
@@ -2446,8 +2429,10 @@ class File::Stat < Object
|
|
|
2446
2429
|
|
|
2447
2430
|
# <!--
|
|
2448
2431
|
# rdoc-file=file.c
|
|
2449
|
-
# -
|
|
2432
|
+
# - new(p1)
|
|
2450
2433
|
# -->
|
|
2434
|
+
# File::Stat.new(file_name) -> stat
|
|
2435
|
+
#
|
|
2451
2436
|
# Create a File::Stat object for the given file name (raising an exception if
|
|
2452
2437
|
# the file doesn't exist).
|
|
2453
2438
|
#
|
|
@@ -2455,31 +2440,16 @@ class File::Stat < Object
|
|
|
2455
2440
|
|
|
2456
2441
|
# <!--
|
|
2457
2442
|
# rdoc-file=file.c
|
|
2458
|
-
# -
|
|
2443
|
+
# - stat <=> other_stat -> -1, 0, 1, nil
|
|
2459
2444
|
# -->
|
|
2460
|
-
# Compares
|
|
2461
|
-
# by comparing `self.mtime` and `other.mtime`.
|
|
2462
|
-
#
|
|
2463
|
-
# Returns:
|
|
2445
|
+
# Compares File::Stat objects by comparing their respective modification times.
|
|
2464
2446
|
#
|
|
2465
|
-
#
|
|
2466
|
-
# * `0`, if the two values are equal.
|
|
2467
|
-
# * `1`, if `self.mtime` is later.
|
|
2468
|
-
# * `nil`, if `other` is not a File::Stat object.
|
|
2469
|
-
#
|
|
2470
|
-
# Examples:
|
|
2447
|
+
# `nil` is returned if `other_stat` is not a File::Stat object
|
|
2471
2448
|
#
|
|
2472
|
-
#
|
|
2473
|
-
#
|
|
2474
|
-
#
|
|
2475
|
-
#
|
|
2476
|
-
# stat0 <=> stat1 # => -1
|
|
2477
|
-
# stat0 <=> stat0.dup # => 0
|
|
2478
|
-
# stat1 <=> stat0 # => 1
|
|
2479
|
-
# stat0 <=> :foo # => nil
|
|
2480
|
-
#
|
|
2481
|
-
# Class File::Stat includes module Comparable, each of whose methods uses
|
|
2482
|
-
# File::Stat#<=> for comparison.
|
|
2449
|
+
# f1 = File.new("f1", "w")
|
|
2450
|
+
# sleep 1
|
|
2451
|
+
# f2 = File.new("f2", "w")
|
|
2452
|
+
# f1.stat <=> f2.stat #=> -1
|
|
2483
2453
|
#
|
|
2484
2454
|
def <=>: (File::Stat other) -> Integer
|
|
2485
2455
|
| (untyped) -> nil
|
data/core/file_test.rbs
CHANGED
|
@@ -145,7 +145,7 @@ module FileTest
|
|
|
145
145
|
# rdoc-file=file.c
|
|
146
146
|
# - File.owned?(file_name) -> true or false
|
|
147
147
|
# -->
|
|
148
|
-
# Returns `true` if the named file exists and the effective
|
|
148
|
+
# Returns `true` if the named file exists and the effective used id of the
|
|
149
149
|
# calling process is the owner of the file.
|
|
150
150
|
#
|
|
151
151
|
# *file_name* can be an IO object.
|