rbs 3.9.4 → 3.10.2
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/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +54 -0
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/ruby.yml +33 -19
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/.gitignore +4 -0
- data/CHANGELOG.md +81 -0
- data/README.md +38 -1
- data/Rakefile +152 -23
- data/config.yml +190 -62
- data/core/array.rbs +96 -46
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +40 -25
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +6 -9
- data/core/enumerable.rbs +90 -3
- data/core/enumerator.rbs +43 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +29 -20
- data/core/file.rbs +49 -19
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +224 -33
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1023 -727
- data/core/integer.rbs +104 -63
- data/core/io/buffer.rbs +21 -10
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +14 -12
- data/core/kernel.rbs +61 -51
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +63 -25
- data/core/module.rbs +101 -23
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +25 -17
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/core/pathname.rbs +1272 -0
- data/core/proc.rbs +30 -24
- data/core/process.rbs +2 -2
- data/core/ractor.rbs +361 -509
- data/core/range.rbs +7 -8
- data/core/rational.rbs +56 -34
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -2
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/signal.rbs +24 -14
- data/core/string.rbs +3164 -1235
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +17 -11
- data/core/thread.rbs +95 -33
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/sigs.md +3 -3
- data/ext/rbs_extension/ast_translation.c +1016 -0
- data/ext/rbs_extension/ast_translation.h +37 -0
- data/ext/rbs_extension/class_constants.c +155 -0
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +7 -1
- data/ext/rbs_extension/compat.h +10 -0
- data/ext/rbs_extension/extconf.rb +25 -1
- data/ext/rbs_extension/legacy_location.c +317 -0
- data/ext/rbs_extension/legacy_location.h +45 -0
- data/ext/rbs_extension/main.c +367 -23
- data/ext/rbs_extension/rbs_extension.h +6 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +24 -0
- data/include/rbs/ast.h +687 -0
- data/include/rbs/defines.h +86 -0
- data/include/rbs/lexer.h +199 -0
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +135 -0
- data/include/rbs/string.h +47 -0
- data/include/rbs/util/rbs_allocator.h +59 -0
- data/include/rbs/util/rbs_assert.h +20 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +6 -67
- data/include/rbs/util/rbs_encoding.h +282 -0
- data/include/rbs/util/rbs_unescape.h +24 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/cli/validate.rb +2 -2
- data/lib/rbs/cli.rb +1 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +5 -5
- data/lib/rbs/environment.rb +64 -59
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +1 -1
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +124 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +14 -0
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +3 -3
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/environment.rbs +57 -6
- data/sig/manifest.yaml +0 -1
- data/sig/parser.rbs +20 -0
- data/sig/resolver/type_name_resolver.rbs +38 -7
- data/sig/types.rbs +4 -1
- data/src/ast.c +1256 -0
- data/src/lexer.c +2956 -0
- data/src/lexer.re +147 -0
- data/src/lexstate.c +205 -0
- data/src/location.c +71 -0
- data/src/parser.c +3507 -0
- data/src/string.c +41 -0
- data/src/util/rbs_allocator.c +165 -0
- data/src/util/rbs_assert.c +19 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +18 -88
- data/src/util/rbs_encoding.c +21308 -0
- data/src/util/rbs_unescape.c +167 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +18 -13
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +68 -48
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -4
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +3 -3
- data/stdlib/pathname/0/pathname.rbs +9 -1379
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +7 -5
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +5 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- 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 +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +11 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +17 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +44 -18
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.h +0 -179
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/lexstate.c +0 -175
- data/ext/rbs_extension/location.c +0 -325
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/constants.c +0 -153
- data/src/ruby_objs.c +0 -799
data/core/kernel.rbs
CHANGED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
# * #print: Prints the given objects to standard output without a newline.
|
|
81
81
|
# * #printf: Prints the string resulting from applying the given format string
|
|
82
82
|
# to any additional arguments.
|
|
83
|
-
# * #putc: Equivalent to
|
|
83
|
+
# * #putc: Equivalent to `$stdout.putc(object)` for the given object.
|
|
84
84
|
# * #puts: Equivalent to `$stdout.puts(*objects)` for the given objects.
|
|
85
85
|
# * #readline: Similar to #gets, but raises an exception at the end of file.
|
|
86
86
|
# * #readlines: Returns an array of the remaining lines from the current
|
|
@@ -718,14 +718,14 @@ module Kernel : BasicObject
|
|
|
718
718
|
# variable `$?` to the process status.
|
|
719
719
|
#
|
|
720
720
|
# This method has potential security vulnerabilities if called with untrusted
|
|
721
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
721
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
722
722
|
#
|
|
723
723
|
# Examples:
|
|
724
724
|
#
|
|
725
725
|
# $ `date` # => "Wed Apr 9 08:56:30 CDT 2003\n"
|
|
726
726
|
# $ `echo oops && exit 99` # => "oops\n"
|
|
727
727
|
# $ $? # => #<Process::Status: pid 17088 exit 99>
|
|
728
|
-
# $ $?.
|
|
728
|
+
# $ $?.exitstatus # => 99
|
|
729
729
|
#
|
|
730
730
|
# The built-in syntax `%x{...}` uses this method.
|
|
731
731
|
#
|
|
@@ -777,6 +777,8 @@ module Kernel : BasicObject
|
|
|
777
777
|
# If *const* is defined as autoload, the file name to be loaded is replaced with
|
|
778
778
|
# *filename*. If *const* is defined but not as autoload, does nothing.
|
|
779
779
|
#
|
|
780
|
+
# Files that are currently being loaded must not be registered for autoload.
|
|
781
|
+
#
|
|
780
782
|
def self?.autoload: (interned _module, String filename) -> NilClass
|
|
781
783
|
|
|
782
784
|
# <!--
|
|
@@ -1002,6 +1004,8 @@ module Kernel : BasicObject
|
|
|
1002
1004
|
# With argument `exception` not given, argument `message` and keyword argument
|
|
1003
1005
|
# `cause` may be given, but argument `backtrace` may not be given.
|
|
1004
1006
|
#
|
|
1007
|
+
# `cause` can not be given as an only argument.
|
|
1008
|
+
#
|
|
1005
1009
|
def self?.fail: () -> bot
|
|
1006
1010
|
| (string message, ?cause: Exception?) -> bot
|
|
1007
1011
|
| (_Exception exception, ?_ToS? message, ?String | Array[String] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> bot
|
|
@@ -1108,6 +1112,8 @@ module Kernel : BasicObject
|
|
|
1108
1112
|
# With argument `exception` not given, argument `message` and keyword argument
|
|
1109
1113
|
# `cause` may be given, but argument `backtrace` may not be given.
|
|
1110
1114
|
#
|
|
1115
|
+
# `cause` can not be given as an only argument.
|
|
1116
|
+
#
|
|
1111
1117
|
alias raise fail
|
|
1112
1118
|
|
|
1113
1119
|
alias self.raise self.fail
|
|
@@ -1116,7 +1122,7 @@ module Kernel : BasicObject
|
|
|
1116
1122
|
# Returns the string resulting from formatting `objects` into `format_string`.
|
|
1117
1123
|
#
|
|
1118
1124
|
# For details on `format_string`, see [Format
|
|
1119
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1125
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1120
1126
|
#
|
|
1121
1127
|
def self?.format: (String format, *untyped args) -> String
|
|
1122
1128
|
|
|
@@ -1127,7 +1133,7 @@ module Kernel : BasicObject
|
|
|
1127
1133
|
# Returns the string resulting from formatting `objects` into `format_string`.
|
|
1128
1134
|
#
|
|
1129
1135
|
# For details on `format_string`, see [Format
|
|
1130
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1136
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1131
1137
|
#
|
|
1132
1138
|
alias sprintf format
|
|
1133
1139
|
|
|
@@ -1218,6 +1224,7 @@ module Kernel : BasicObject
|
|
|
1218
1224
|
# loop do
|
|
1219
1225
|
# print "Input: "
|
|
1220
1226
|
# line = gets
|
|
1227
|
+
# # break if q, Q is entered or EOF signal (Ctrl-D on Unix, Ctrl-Z on windows) is sent
|
|
1221
1228
|
# break if !line or line =~ /^q/i
|
|
1222
1229
|
# # ...
|
|
1223
1230
|
# end
|
|
@@ -1246,7 +1253,7 @@ module Kernel : BasicObject
|
|
|
1246
1253
|
# Creates an IO object connected to the given file.
|
|
1247
1254
|
#
|
|
1248
1255
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1249
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
1256
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1250
1257
|
#
|
|
1251
1258
|
# With no block given, file stream is returned:
|
|
1252
1259
|
#
|
|
@@ -1324,7 +1331,7 @@ module Kernel : BasicObject
|
|
|
1324
1331
|
# io.write(sprintf(format_string, *objects))
|
|
1325
1332
|
#
|
|
1326
1333
|
# For details on `format_string`, see [Format
|
|
1327
|
-
# Specifications](rdoc-ref:format_specifications.rdoc).
|
|
1334
|
+
# Specifications](rdoc-ref:language/format_specifications.rdoc).
|
|
1328
1335
|
#
|
|
1329
1336
|
# With the single argument `format_string`, formats `objects` into the string,
|
|
1330
1337
|
# then writes the formatted string to $stdout:
|
|
@@ -1463,7 +1470,9 @@ module Kernel : BasicObject
|
|
|
1463
1470
|
# Kernel.srand may be used to ensure that sequences of random numbers are
|
|
1464
1471
|
# reproducible between different runs of a program.
|
|
1465
1472
|
#
|
|
1466
|
-
#
|
|
1473
|
+
# Related: Random.rand.
|
|
1474
|
+
# rand(100.0) # => 64 (Integer because max.to_i is 100)
|
|
1475
|
+
# Random.rand(100.0) # => 30.315320967824523
|
|
1467
1476
|
#
|
|
1468
1477
|
def self?.rand: (?0) -> Float
|
|
1469
1478
|
| (int arg0) -> Integer
|
|
@@ -1585,7 +1594,8 @@ module Kernel : BasicObject
|
|
|
1585
1594
|
# IO objects.
|
|
1586
1595
|
#
|
|
1587
1596
|
# Argument `timeout` is a numeric value (such as integer or float) timeout
|
|
1588
|
-
# interval in seconds.
|
|
1597
|
+
# interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
|
|
1598
|
+
# and `Float::INFINITY` means no timeout.
|
|
1589
1599
|
#
|
|
1590
1600
|
# The method monitors the IO objects given in all three arrays, waiting for some
|
|
1591
1601
|
# to be ready; returns a 3-element array whose elements are:
|
|
@@ -1773,58 +1783,58 @@ module Kernel : BasicObject
|
|
|
1773
1783
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1774
1784
|
# and returns `true` or `false`;
|
|
1775
1785
|
# for a non-existent entity, returns `false` (does not raise exception):
|
|
1776
|
-
#
|
|
1777
|
-
#
|
|
1778
|
-
#
|
|
1779
|
-
#
|
|
1780
|
-
#
|
|
1781
|
-
#
|
|
1782
|
-
#
|
|
1783
|
-
#
|
|
1784
|
-
#
|
|
1785
|
-
#
|
|
1786
|
-
#
|
|
1787
|
-
#
|
|
1788
|
-
#
|
|
1789
|
-
#
|
|
1790
|
-
#
|
|
1791
|
-
#
|
|
1792
|
-
#
|
|
1793
|
-
#
|
|
1794
|
-
#
|
|
1795
|
-
#
|
|
1796
|
-
#
|
|
1797
|
-
#
|
|
1798
|
-
#
|
|
1786
|
+
# Character|Test
|
|
1787
|
+
# ---------|-------------------------------------------------------------------
|
|
1788
|
+
# `'b'` |Whether the entity is a block device.
|
|
1789
|
+
# `'c'` |Whether the entity is a character device.
|
|
1790
|
+
# `'d'` |Whether the entity is a directory.
|
|
1791
|
+
# `'e'` |Whether the entity is an existing entity.
|
|
1792
|
+
# `'f'` |Whether the entity is an existing regular file.
|
|
1793
|
+
# `'g'` |Whether the entity's setgid bit is set.
|
|
1794
|
+
# `'G'` |Whether the entity's group ownership is equal to the caller's.
|
|
1795
|
+
# `'k'` |Whether the entity's sticky bit is set.
|
|
1796
|
+
# `'l'` |Whether the entity is a symbolic link.
|
|
1797
|
+
# `'o'` |Whether the entity is owned by the caller's effective uid.
|
|
1798
|
+
# `'O'` |Like `'o'`, but uses the real uid (not the effective uid).
|
|
1799
|
+
# `'p'` |Whether the entity is a FIFO device (named pipe).
|
|
1800
|
+
# `'r'` |Whether the entity is readable by the caller's effective uid/gid.
|
|
1801
|
+
# `'R'` |Like `'r'`, but uses the real uid/gid (not the effective uid/gid).
|
|
1802
|
+
# `'S'` |Whether the entity is a socket.
|
|
1803
|
+
# `'u'` |Whether the entity's setuid bit is set.
|
|
1804
|
+
# `'w'` |Whether the entity is writable by the caller's effective uid/gid.
|
|
1805
|
+
# `'W'` |Like `'w'`, but uses the real uid/gid (not the effective uid/gid).
|
|
1806
|
+
# `'x'` |Whether the entity is executable by the caller's effective uid/gid.
|
|
1807
|
+
# `'X'` |Like `'x'`, but uses the real uid/gid (not the effective uid/git).
|
|
1808
|
+
# `'z'` |Whether the entity exists and is of length zero.
|
|
1799
1809
|
# * This test operates only on the entity at `path0`,
|
|
1800
1810
|
# and returns an integer size or `nil`:
|
|
1801
|
-
#
|
|
1802
|
-
#
|
|
1803
|
-
#
|
|
1811
|
+
# Character|Test
|
|
1812
|
+
# ---------|--------------------------------------------------------------------------------------------
|
|
1813
|
+
# `'s'` |Returns positive integer size if the entity exists and has non-zero length, `nil` otherwise.
|
|
1804
1814
|
# * Each of these tests operates only on the entity at `path0`,
|
|
1805
1815
|
# and returns a Time object;
|
|
1806
1816
|
# raises an exception if the entity does not exist:
|
|
1807
|
-
#
|
|
1808
|
-
#
|
|
1809
|
-
#
|
|
1810
|
-
#
|
|
1811
|
-
#
|
|
1817
|
+
# Character|Test
|
|
1818
|
+
# ---------|--------------------------------------
|
|
1819
|
+
# `'A'` |Last access time for the entity.
|
|
1820
|
+
# `'C'` |Last change time for the entity.
|
|
1821
|
+
# `'M'` |Last modification time for the entity.
|
|
1812
1822
|
# * Each of these tests operates on the modification time (`mtime`)
|
|
1813
1823
|
# of each of the entities at `path0` and `path1`,
|
|
1814
1824
|
# and returns a `true` or `false`;
|
|
1815
1825
|
# returns `false` if either entity does not exist:
|
|
1816
|
-
#
|
|
1817
|
-
#
|
|
1818
|
-
#
|
|
1819
|
-
#
|
|
1820
|
-
#
|
|
1826
|
+
# Character|Test
|
|
1827
|
+
# ---------|---------------------------------------------------------------
|
|
1828
|
+
# `'<'` |Whether the `mtime` at `path0` is less than that at `path1`.
|
|
1829
|
+
# `'='` |Whether the `mtime` at `path0` is equal to that at `path1`.
|
|
1830
|
+
# `'>'` |Whether the `mtime` at `path0` is greater than that at `path1`.
|
|
1821
1831
|
# * This test operates on the content of each of the entities at `path0` and
|
|
1822
1832
|
# `path1`,
|
|
1823
1833
|
# and returns a `true` or `false`;
|
|
1824
1834
|
# returns `false` if either entity does not exist:
|
|
1825
|
-
#
|
|
1826
|
-
#
|
|
1827
|
-
#
|
|
1835
|
+
# Character|Test
|
|
1836
|
+
# ---------|---------------------------------------------
|
|
1837
|
+
# `'-'` |Whether the entities exist and are identical.
|
|
1828
1838
|
#
|
|
1829
1839
|
def self?.test: (String | Integer cmd, String | IO file1, ?String | IO file2) -> (TrueClass | FalseClass | Time | nil | Integer)
|
|
1830
1840
|
|
|
@@ -1901,7 +1911,7 @@ module Kernel : BasicObject
|
|
|
1901
1911
|
# * Invoking the executable at `exe_path`.
|
|
1902
1912
|
#
|
|
1903
1913
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1904
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
1914
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1905
1915
|
#
|
|
1906
1916
|
# The new process is created using the [exec system
|
|
1907
1917
|
# call](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/e
|
|
@@ -1993,7 +2003,7 @@ module Kernel : BasicObject
|
|
|
1993
2003
|
# * Invoking the executable at `exe_path`.
|
|
1994
2004
|
#
|
|
1995
2005
|
# This method has potential security vulnerabilities if called with untrusted
|
|
1996
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2006
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
1997
2007
|
#
|
|
1998
2008
|
# Returns the process ID (pid) of the new process, without waiting for it to
|
|
1999
2009
|
# complete.
|
|
@@ -2096,7 +2106,7 @@ module Kernel : BasicObject
|
|
|
2096
2106
|
# * Invoking the executable at `exe_path`.
|
|
2097
2107
|
#
|
|
2098
2108
|
# This method has potential security vulnerabilities if called with untrusted
|
|
2099
|
-
# input; see [Command Injection](rdoc-ref:command_injection.rdoc).
|
|
2109
|
+
# input; see [Command Injection](rdoc-ref:security/command_injection.rdoc).
|
|
2100
2110
|
#
|
|
2101
2111
|
# Returns:
|
|
2102
2112
|
#
|
data/core/marshal.rbs
CHANGED
|
@@ -147,7 +147,7 @@ module Marshal
|
|
|
147
147
|
# * anonymous Class/Module.
|
|
148
148
|
# * objects which are related to system (ex: Dir, File::Stat, IO, File, Socket
|
|
149
149
|
# and so on)
|
|
150
|
-
# * an instance of MatchData,
|
|
150
|
+
# * an instance of MatchData, Method, UnboundMethod, Proc, Thread,
|
|
151
151
|
# ThreadGroup, Continuation
|
|
152
152
|
# * objects which define singleton methods
|
|
153
153
|
#
|
data/core/match_data.rbs
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
# * `$'` is Regexp.last_match`.post_match`;
|
|
42
42
|
# * `$+` is Regexp.last_match`[ -1 ]` (the last capture).
|
|
43
43
|
#
|
|
44
|
-
# See also
|
|
44
|
+
# See also Regexp@Global+Variables.
|
|
45
45
|
#
|
|
46
46
|
class MatchData
|
|
47
47
|
type capture = String | Symbol | int
|
data/core/math.rbs
CHANGED
|
@@ -410,6 +410,27 @@ module Math
|
|
|
410
410
|
#
|
|
411
411
|
def self.exp: (double x) -> Float
|
|
412
412
|
|
|
413
|
+
# <!--
|
|
414
|
+
# rdoc-file=math.c
|
|
415
|
+
# - Math.expm1(x) -> float
|
|
416
|
+
# -->
|
|
417
|
+
# Returns "exp(x) - 1", `e` raised to the `x` power, minus 1.
|
|
418
|
+
#
|
|
419
|
+
# * Domain: `[-INFINITY, INFINITY]`.
|
|
420
|
+
# * Range: `[-1.0, INFINITY]`.
|
|
421
|
+
#
|
|
422
|
+
# Examples:
|
|
423
|
+
#
|
|
424
|
+
# expm1(-INFINITY) # => 0.0
|
|
425
|
+
# expm1(-1.0) # => -0.6321205588285577 # 1.0/E - 1
|
|
426
|
+
# expm1(0.0) # => 0.0
|
|
427
|
+
# expm1(0.5) # => 0.6487212707001282 # sqrt(E) - 1
|
|
428
|
+
# expm1(1.0) # => 1.718281828459045 # E - 1
|
|
429
|
+
# expm1(2.0) # => 6.38905609893065 # E**2 - 1
|
|
430
|
+
# expm1(INFINITY) # => Infinity
|
|
431
|
+
#
|
|
432
|
+
def self.expm1: (double x) -> Float
|
|
433
|
+
|
|
413
434
|
# <!--
|
|
414
435
|
# rdoc-file=math.c
|
|
415
436
|
# - Math.frexp(x) -> [fraction, exponent]
|
|
@@ -525,9 +546,8 @@ module Math
|
|
|
525
546
|
#
|
|
526
547
|
# [Math.log(Math.gamma(x).abs), Math.gamma(x) < 0 ? -1 : 1]
|
|
527
548
|
#
|
|
528
|
-
# See [
|
|
529
|
-
# function](https://en.wikipedia.org/wiki/Gamma_function#
|
|
530
|
-
# .
|
|
549
|
+
# See [log gamma
|
|
550
|
+
# function](https://en.wikipedia.org/wiki/Gamma_function#Log-gamma_function).
|
|
531
551
|
#
|
|
532
552
|
# * Domain: `(-INFINITY, INFINITY]`.
|
|
533
553
|
# * Range of first element: `(-INFINITY, INFINITY]`.
|
|
@@ -603,6 +623,25 @@ module Math
|
|
|
603
623
|
#
|
|
604
624
|
def self.log10: (double x) -> Float
|
|
605
625
|
|
|
626
|
+
# <!--
|
|
627
|
+
# rdoc-file=math.c
|
|
628
|
+
# - Math.log1p(x) -> float
|
|
629
|
+
# -->
|
|
630
|
+
# Returns "log(x + 1)", the base E
|
|
631
|
+
# [logarithm](https://en.wikipedia.org/wiki/Logarithm) of (`x` + 1).
|
|
632
|
+
#
|
|
633
|
+
# * Domain: `[-1, INFINITY]`.
|
|
634
|
+
# * Range: `[-INFINITY, INFINITY]`.
|
|
635
|
+
#
|
|
636
|
+
# Examples:
|
|
637
|
+
#
|
|
638
|
+
# log1p(-1.0) # => -Infinity
|
|
639
|
+
# log1p(0.0) # => 0.0
|
|
640
|
+
# log1p(E - 1) # => 1.0
|
|
641
|
+
# log1p(INFINITY) # => Infinity
|
|
642
|
+
#
|
|
643
|
+
def self.log1p: (double x) -> Float
|
|
644
|
+
|
|
606
645
|
# <!--
|
|
607
646
|
# rdoc-file=math.c
|
|
608
647
|
# - Math.log2(x) -> float
|
data/core/method.rbs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# <!-- rdoc-file=proc.c -->
|
|
2
|
-
# Method objects are created by Object#method, and are associated with a
|
|
2
|
+
# `Method` objects are created by Object#method, and are associated with a
|
|
3
3
|
# particular object (not just with a class). They may be used to invoke the
|
|
4
4
|
# method within the object, and as a block associated with an iterator. They
|
|
5
5
|
# may also be unbound from one object (creating an UnboundMethod) and bound to
|
|
@@ -126,7 +126,9 @@ class Method
|
|
|
126
126
|
|
|
127
127
|
# <!--
|
|
128
128
|
# rdoc-file=proc.c
|
|
129
|
-
# - meth.call(args, ...)
|
|
129
|
+
# - meth.call(args, ...) -> obj
|
|
130
|
+
# - meth[args, ...] -> obj
|
|
131
|
+
# - method === obj -> result_of_method
|
|
130
132
|
# -->
|
|
131
133
|
# Invokes the *meth* with the specified arguments, returning the method's return
|
|
132
134
|
# value.
|
|
@@ -135,23 +137,32 @@ class Method
|
|
|
135
137
|
# m.call(3) #=> 15
|
|
136
138
|
# m.call(20) #=> 32
|
|
137
139
|
#
|
|
140
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
141
|
+
# a case statement.
|
|
142
|
+
#
|
|
143
|
+
# require 'prime'
|
|
144
|
+
#
|
|
145
|
+
# case 1373
|
|
146
|
+
# when Prime.method(:prime?)
|
|
147
|
+
# # ...
|
|
148
|
+
# end
|
|
149
|
+
#
|
|
138
150
|
def call: (?) -> untyped
|
|
139
151
|
|
|
140
152
|
# <!--
|
|
141
153
|
# rdoc-file=proc.c
|
|
142
|
-
# -
|
|
154
|
+
# - self << g -> a_proc
|
|
143
155
|
# -->
|
|
144
|
-
# Returns a proc that is the composition of
|
|
145
|
-
# returned proc takes a variable number of arguments, calls *g* with them then
|
|
146
|
-
# calls this method with the result.
|
|
156
|
+
# Returns a proc that is the composition of the given `g` and this method.
|
|
147
157
|
#
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
158
|
+
# The returned proc takes a variable number of arguments. It first calls `g`
|
|
159
|
+
# with the arguments, then calls `self` with the return value of `g`.
|
|
160
|
+
#
|
|
161
|
+
# def f(ary) = ary << 'in f'
|
|
151
162
|
#
|
|
152
163
|
# f = self.method(:f)
|
|
153
|
-
# g = proc {|
|
|
154
|
-
#
|
|
164
|
+
# g = proc { |ary| ary << 'in proc' }
|
|
165
|
+
# (f << g).call([]) # => ["in proc", "in f"]
|
|
155
166
|
#
|
|
156
167
|
def <<: (Proc::_Callable g) -> Proc
|
|
157
168
|
|
|
@@ -163,23 +174,32 @@ class Method
|
|
|
163
174
|
# m.call(3) #=> 15
|
|
164
175
|
# m.call(20) #=> 32
|
|
165
176
|
#
|
|
177
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
178
|
+
# a case statement.
|
|
179
|
+
#
|
|
180
|
+
# require 'prime'
|
|
181
|
+
#
|
|
182
|
+
# case 1373
|
|
183
|
+
# when Prime.method(:prime?)
|
|
184
|
+
# # ...
|
|
185
|
+
# end
|
|
186
|
+
#
|
|
166
187
|
alias === call
|
|
167
188
|
|
|
168
189
|
# <!--
|
|
169
190
|
# rdoc-file=proc.c
|
|
170
|
-
# -
|
|
191
|
+
# - self >> g -> a_proc
|
|
171
192
|
# -->
|
|
172
|
-
# Returns a proc that is the composition of this method and the given
|
|
173
|
-
# returned proc takes a variable number of arguments, calls this method with
|
|
174
|
-
# them then calls *g* with the result.
|
|
193
|
+
# Returns a proc that is the composition of this method and the given `g`.
|
|
175
194
|
#
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
195
|
+
# The returned proc takes a variable number of arguments. It first calls `self`
|
|
196
|
+
# with the arguments, then calls `g` with the return value of `self`.
|
|
197
|
+
#
|
|
198
|
+
# def f(ary) = ary << 'in f'
|
|
179
199
|
#
|
|
180
200
|
# f = self.method(:f)
|
|
181
|
-
# g = proc {|
|
|
182
|
-
#
|
|
201
|
+
# g = proc { |ary| ary << 'in proc' }
|
|
202
|
+
# (f >> g).call([]) # => ["in f", "in proc"]
|
|
183
203
|
#
|
|
184
204
|
def >>: (Proc::_Callable g) -> Proc
|
|
185
205
|
|
|
@@ -191,6 +211,16 @@ class Method
|
|
|
191
211
|
# m.call(3) #=> 15
|
|
192
212
|
# m.call(20) #=> 32
|
|
193
213
|
#
|
|
214
|
+
# Using Method#=== allows a method object to be the target of a `when` clause in
|
|
215
|
+
# a case statement.
|
|
216
|
+
#
|
|
217
|
+
# require 'prime'
|
|
218
|
+
#
|
|
219
|
+
# case 1373
|
|
220
|
+
# when Prime.method(:prime?)
|
|
221
|
+
# # ...
|
|
222
|
+
# end
|
|
223
|
+
#
|
|
194
224
|
alias [] call
|
|
195
225
|
|
|
196
226
|
# <!--
|
|
@@ -359,10 +389,18 @@ class Method
|
|
|
359
389
|
|
|
360
390
|
# <!--
|
|
361
391
|
# rdoc-file=proc.c
|
|
362
|
-
# - meth.source_location -> [String, Integer]
|
|
392
|
+
# - meth.source_location -> [String, Integer, Integer, Integer, Integer]
|
|
363
393
|
# -->
|
|
364
|
-
# Returns the
|
|
365
|
-
#
|
|
394
|
+
# Returns the location where the method was defined. The returned Array
|
|
395
|
+
# contains:
|
|
396
|
+
# (1) the Ruby source filename
|
|
397
|
+
# (2) the line number where the definition starts
|
|
398
|
+
# (3) the column number where the definition starts
|
|
399
|
+
# (4) the line number where the definition ends
|
|
400
|
+
# (5) the column number where the definitions ends
|
|
401
|
+
#
|
|
402
|
+
# This method will return `nil` if the method was not defined in Ruby (i.e.
|
|
403
|
+
# native).
|
|
366
404
|
#
|
|
367
405
|
def source_location: () -> [String, Integer]?
|
|
368
406
|
|
|
@@ -370,8 +408,8 @@ class Method
|
|
|
370
408
|
# rdoc-file=proc.c
|
|
371
409
|
# - meth.super_method -> method
|
|
372
410
|
# -->
|
|
373
|
-
# Returns a Method of superclass which would be called when super is used or
|
|
374
|
-
# if there is no method on superclass.
|
|
411
|
+
# Returns a `Method` of superclass which would be called when super is used or
|
|
412
|
+
# nil if there is no method on superclass.
|
|
375
413
|
#
|
|
376
414
|
def super_method: () -> Method?
|
|
377
415
|
|
data/core/module.rbs
CHANGED
|
@@ -114,12 +114,15 @@ class Module < Object
|
|
|
114
114
|
|
|
115
115
|
# <!--
|
|
116
116
|
# rdoc-file=object.c
|
|
117
|
-
# -
|
|
117
|
+
# - self < other -> true, false, or nil
|
|
118
118
|
# -->
|
|
119
|
-
# Returns
|
|
120
|
-
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
119
|
+
# Returns whether `self` is a subclass of `other`, or `nil` if there is no
|
|
120
|
+
# relationship between the two:
|
|
121
|
+
#
|
|
122
|
+
# Float < Numeric # => true
|
|
123
|
+
# Numeric < Float # => false
|
|
124
|
+
# Float < Float # => false
|
|
125
|
+
# Float < Hash # => nil
|
|
123
126
|
#
|
|
124
127
|
def <: (Module other) -> bool?
|
|
125
128
|
|
|
@@ -135,14 +138,29 @@ class Module < Object
|
|
|
135
138
|
|
|
136
139
|
# <!--
|
|
137
140
|
# rdoc-file=object.c
|
|
138
|
-
# -
|
|
141
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
139
142
|
# -->
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
#
|
|
143
|
+
# Compares `self` and `other`.
|
|
144
|
+
#
|
|
145
|
+
# Returns:
|
|
146
|
+
#
|
|
147
|
+
# * `-1`, if `self` includes `other`, if or `self` is a subclass of `other`.
|
|
148
|
+
# * `0`, if `self` and `other` are the same.
|
|
149
|
+
# * `1`, if `other` includes `self`, or if `other` is a subclass of `self`.
|
|
150
|
+
# * `nil`, if none of the above is true.
|
|
151
|
+
#
|
|
152
|
+
# Examples:
|
|
143
153
|
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
154
|
+
# # Class Array includes module Enumerable.
|
|
155
|
+
# Array <=> Enumerable # => -1
|
|
156
|
+
# Enumerable <=> Enumerable # => 0
|
|
157
|
+
# Enumerable <=> Array # => 1
|
|
158
|
+
# # Class File is a subclass of class IO.
|
|
159
|
+
# File <=> IO # => -1
|
|
160
|
+
# File <=> File # => 0
|
|
161
|
+
# IO <=> File # => 1
|
|
162
|
+
# # Class File has no relationship to class String.
|
|
163
|
+
# File <=> String # => nil
|
|
146
164
|
#
|
|
147
165
|
def <=>: (untyped other) -> Integer?
|
|
148
166
|
|
|
@@ -328,6 +346,8 @@ class Module < Object
|
|
|
328
346
|
# replaced with *filename*. If *const* is defined but not as autoload, does
|
|
329
347
|
# nothing.
|
|
330
348
|
#
|
|
349
|
+
# Files that are currently being loaded must not be registered for autoload.
|
|
350
|
+
#
|
|
331
351
|
def autoload: (interned _module, String filename) -> NilClass
|
|
332
352
|
|
|
333
353
|
# <!--
|
|
@@ -487,6 +507,31 @@ class Module < Object
|
|
|
487
507
|
#
|
|
488
508
|
# Added :FOO
|
|
489
509
|
#
|
|
510
|
+
# If we define a class using the `class` keyword, `const_added` runs before
|
|
511
|
+
# `inherited`:
|
|
512
|
+
#
|
|
513
|
+
# module M
|
|
514
|
+
# def self.const_added(const_name)
|
|
515
|
+
# super
|
|
516
|
+
# p :const_added
|
|
517
|
+
# end
|
|
518
|
+
#
|
|
519
|
+
# parent = Class.new do
|
|
520
|
+
# def self.inherited(subclass)
|
|
521
|
+
# super
|
|
522
|
+
# p :inherited
|
|
523
|
+
# end
|
|
524
|
+
# end
|
|
525
|
+
#
|
|
526
|
+
# class Child < parent
|
|
527
|
+
# end
|
|
528
|
+
# end
|
|
529
|
+
#
|
|
530
|
+
# *produces:*
|
|
531
|
+
#
|
|
532
|
+
# :const_added
|
|
533
|
+
# :inherited
|
|
534
|
+
#
|
|
490
535
|
def const_added: (Symbol) -> void
|
|
491
536
|
|
|
492
537
|
# <!--
|
|
@@ -1321,19 +1366,52 @@ class Module < Object
|
|
|
1321
1366
|
# - protected(method_name, method_name, ...) -> array
|
|
1322
1367
|
# - protected(array) -> array
|
|
1323
1368
|
# -->
|
|
1324
|
-
#
|
|
1325
|
-
#
|
|
1326
|
-
#
|
|
1327
|
-
#
|
|
1328
|
-
#
|
|
1329
|
-
#
|
|
1369
|
+
# Sets the visibility of a section or of a list of method names as protected.
|
|
1370
|
+
# Accepts no arguments, a splat of method names (symbols or strings) or an array
|
|
1371
|
+
# of method names. Returns the arguments that it received.
|
|
1372
|
+
#
|
|
1373
|
+
# ## Important difference between protected in other languages
|
|
1374
|
+
#
|
|
1375
|
+
# Protected methods in Ruby are different from other languages such as Java,
|
|
1376
|
+
# where methods are marked as protected to give access to subclasses. In Ruby,
|
|
1377
|
+
# subclasses **already have access to all methods defined in the parent class**,
|
|
1378
|
+
# even private ones.
|
|
1379
|
+
#
|
|
1380
|
+
# Marking a method as protected allows **different objects of the same class**
|
|
1381
|
+
# to call it.
|
|
1382
|
+
#
|
|
1383
|
+
# One use case is for comparison methods, such as `==`, if we want to expose a
|
|
1384
|
+
# method for comparison between objects of the same class without making the
|
|
1385
|
+
# method public to objects of other classes.
|
|
1386
|
+
#
|
|
1387
|
+
# ## Performance considerations
|
|
1388
|
+
#
|
|
1389
|
+
# Protected methods are slower than others because they can't use inline cache.
|
|
1390
|
+
#
|
|
1391
|
+
# ## Example
|
|
1392
|
+
#
|
|
1393
|
+
# class Account
|
|
1394
|
+
# # Mark balance as protected, so that we can compare between accounts
|
|
1395
|
+
# # without making it public.
|
|
1396
|
+
# attr_reader :balance
|
|
1397
|
+
# protected :balance
|
|
1398
|
+
#
|
|
1399
|
+
# def initialize(balance)
|
|
1400
|
+
# @balance = balance
|
|
1401
|
+
# end
|
|
1402
|
+
#
|
|
1403
|
+
# def >(other)
|
|
1404
|
+
# # The invocation to `other.balance` is allowed because `other` is a
|
|
1405
|
+
# # different object of the same class (Account).
|
|
1406
|
+
# balance > other.balance
|
|
1407
|
+
# end
|
|
1408
|
+
# end
|
|
1330
1409
|
#
|
|
1331
|
-
#
|
|
1332
|
-
#
|
|
1333
|
-
# behavior is different from Java's protected method. Usually `private` should
|
|
1334
|
-
# be used.
|
|
1410
|
+
# account1 = Account.new(100)
|
|
1411
|
+
# account2 = Account.new(50)
|
|
1335
1412
|
#
|
|
1336
|
-
#
|
|
1413
|
+
# account1 > account2 # => true (works)
|
|
1414
|
+
# account1.balance # => NoMethodError (fails because balance is not public)
|
|
1337
1415
|
#
|
|
1338
1416
|
# To show a private method on RDoc, use `:doc:` instead of this.
|
|
1339
1417
|
#
|
|
@@ -1578,7 +1656,7 @@ class Module < Object
|
|
|
1578
1656
|
# m.name #=> nil
|
|
1579
1657
|
#
|
|
1580
1658
|
# c = Class.new
|
|
1581
|
-
# c.set_temporary_name("MyClass(with description)")
|
|
1659
|
+
# c.set_temporary_name("MyClass(with description)") # => MyClass(with description)
|
|
1582
1660
|
#
|
|
1583
1661
|
# c.new # => #<MyClass(with description):0x0....>
|
|
1584
1662
|
#
|