rbs 3.10.4 → 4.0.0
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/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +7 -5
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/ruby.yml +16 -26
- data/.github/workflows/rust.yml +95 -0
- data/.github/workflows/typecheck.yml +1 -1
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +2 -2
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +19 -0
- data/CHANGELOG.md +202 -2
- data/Rakefile +9 -23
- data/Steepfile +2 -0
- data/config.yml +457 -13
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +66 -55
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +6 -6
- data/core/enumerable.rbs +105 -91
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +24 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +47 -36
- data/core/file.rbs +242 -169
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +42 -68
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -75
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +192 -146
- data/core/kernel.rbs +198 -147
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -8
- data/core/module.rbs +148 -88
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +53 -50
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -34
- data/core/process.rbs +221 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +21 -3
- data/core/range.rbs +152 -49
- data/core/rational.rbs +5 -56
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -116
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +318 -298
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -41
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +576 -0
- data/docs/syntax.md +46 -16
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +595 -98
- data/ext/rbs_extension/class_constants.c +30 -0
- data/ext/rbs_extension/class_constants.h +15 -0
- data/ext/rbs_extension/legacy_location.c +30 -53
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +125 -24
- data/include/rbs/ast.h +485 -150
- data/include/rbs/lexer.h +11 -4
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +20 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +409 -0
- data/lib/rbs/ast/ruby/comment_block.rb +245 -0
- data/lib/rbs/ast/ruby/declarations.rb +281 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +723 -0
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +105 -20
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +62 -125
- data/lib/rbs/cli.rb +55 -23
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -4
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/collection.rb +0 -1
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +119 -63
- data/lib/rbs/definition_builder/method_builder.rb +65 -30
- data/lib/rbs/definition_builder.rb +177 -20
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +338 -155
- data/lib/rbs/environment_loader.rb +2 -2
- data/lib/rbs/errors.rb +30 -20
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +542 -0
- data/lib/rbs/location_aux.rb +36 -4
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/namespace.rb +0 -7
- data/lib/rbs/parser_aux.rb +31 -8
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +3 -20
- data/lib/rbs/prototype/runtime.rb +10 -2
- data/lib/rbs/resolver/type_name_resolver.rb +0 -8
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +4 -3
- data/lib/rbs/test/type_check.rb +5 -2
- data/lib/rbs/type_name.rb +1 -8
- data/lib/rbs/types.rb +88 -78
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +12 -1
- data/rbs.gemspec +3 -2
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/schema/typeParam.json +17 -1
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +421 -0
- data/sig/ast/ruby/comment_block.rbs +127 -0
- data/sig/ast/ruby/declarations.rbs +158 -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 +178 -0
- data/sig/buffer.rbs +63 -5
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -0
- data/sig/definition_builder.rbs +3 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +37 -81
- data/sig/errors.rbs +26 -20
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +124 -0
- data/sig/location.rbs +32 -7
- data/sig/locator.rbs +0 -2
- data/sig/method_builder.rbs +9 -4
- data/sig/namespace.rbs +0 -5
- data/sig/parser.rbs +47 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +0 -3
- data/sig/source.rbs +48 -0
- data/sig/type_param.rbs +13 -8
- data/sig/typename.rbs +0 -5
- data/sig/types.rbs +6 -7
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +491 -143
- data/src/lexer.c +1552 -1314
- data/src/lexer.re +7 -0
- data/src/lexstate.c +8 -1
- data/src/location.c +8 -48
- data/src/parser.c +1107 -409
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +140 -126
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +158 -131
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -30
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +23 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +62 -9
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +9 -9
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +31 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +9 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +6 -6
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +66 -3
data/core/file_test.rbs
CHANGED
|
@@ -269,7 +269,7 @@ module FileTest
|
|
|
269
269
|
# -->
|
|
270
270
|
# If *file_name* is readable by others, returns an integer representing the file
|
|
271
271
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
|
272
|
-
# bits is platform dependent; on Unix systems, see
|
|
272
|
+
# bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
273
273
|
#
|
|
274
274
|
# *file_name* can be an IO object.
|
|
275
275
|
#
|
|
@@ -285,7 +285,7 @@ module FileTest
|
|
|
285
285
|
# -->
|
|
286
286
|
# If *file_name* is writable by others, returns an integer representing the file
|
|
287
287
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
|
288
|
-
# bits is platform dependent; on Unix systems, see
|
|
288
|
+
# bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
289
289
|
#
|
|
290
290
|
# *file_name* can be an IO object.
|
|
291
291
|
#
|
data/core/float.rbs
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
#
|
|
13
13
|
# Others cannot; among these are the transcendental numbers, including:
|
|
14
14
|
#
|
|
15
|
-
# * Pi,
|
|
15
|
+
# * Pi, <em>π</em>: in mathematics, a number of infinite precision:
|
|
16
16
|
# 3.1415926535897932384626433... (to 25 places); in Ruby, it is of limited
|
|
17
17
|
# precision (in this case, to 16 decimal places):
|
|
18
18
|
#
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
# Others do not:
|
|
33
33
|
#
|
|
34
34
|
# * In mathematics, 2/3 as a decimal number is an infinitely-repeating
|
|
35
|
-
# decimal: 0.666... (forever); in Ruby,
|
|
36
|
-
# this case, to 16 decimal places):
|
|
35
|
+
# decimal: 0.666... (forever); in Ruby, <code>2.0/3</code> is of limited
|
|
36
|
+
# precision (in this case, to 16 decimal places):
|
|
37
37
|
#
|
|
38
38
|
# 2.0/3 # => 0.6666666666666666
|
|
39
39
|
#
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
#
|
|
140
140
|
# Others cannot; among these are the transcendental numbers, including:
|
|
141
141
|
#
|
|
142
|
-
# * Pi,
|
|
142
|
+
# * Pi, <em>π</em>: in mathematics, a number of infinite precision:
|
|
143
143
|
# 3.1415926535897932384626433... (to 25 places); in Ruby, it is of limited
|
|
144
144
|
# precision (in this case, to 16 decimal places):
|
|
145
145
|
#
|
|
@@ -159,8 +159,8 @@
|
|
|
159
159
|
# Others do not:
|
|
160
160
|
#
|
|
161
161
|
# * In mathematics, 2/3 as a decimal number is an infinitely-repeating
|
|
162
|
-
# decimal: 0.666... (forever); in Ruby,
|
|
163
|
-
# this case, to 16 decimal places):
|
|
162
|
+
# decimal: 0.666... (forever); in Ruby, <code>2.0/3</code> is of limited
|
|
163
|
+
# precision (in this case, to 16 decimal places):
|
|
164
164
|
#
|
|
165
165
|
# 2.0/3 # => 0.6666666666666666
|
|
166
166
|
#
|
|
@@ -336,8 +336,6 @@ class Float < Numeric
|
|
|
336
336
|
def +: (Complex) -> Complex
|
|
337
337
|
| (Numeric) -> Float
|
|
338
338
|
|
|
339
|
-
def +@: () -> Float
|
|
340
|
-
|
|
341
339
|
# <!--
|
|
342
340
|
# rdoc-file=numeric.c
|
|
343
341
|
# - self - other -> numeric
|
|
@@ -392,7 +390,8 @@ class Float < Numeric
|
|
|
392
390
|
# 2.0 < Rational(3, 1) # => true
|
|
393
391
|
# 2.0 < 2.0 # => false
|
|
394
392
|
#
|
|
395
|
-
#
|
|
393
|
+
# <code>Float::NAN < Float::NAN</code> returns an implementation-dependent
|
|
394
|
+
# value.
|
|
396
395
|
#
|
|
397
396
|
def <: (Numeric) -> bool
|
|
398
397
|
|
|
@@ -409,7 +408,8 @@ class Float < Numeric
|
|
|
409
408
|
# 2.0 <= 2.0 # => true
|
|
410
409
|
# 2.0 <= 1.0 # => false
|
|
411
410
|
#
|
|
412
|
-
#
|
|
411
|
+
# <code>Float::NAN <= Float::NAN</code> returns an implementation-dependent
|
|
412
|
+
# value.
|
|
413
413
|
#
|
|
414
414
|
def <=: (Numeric) -> bool
|
|
415
415
|
|
|
@@ -421,7 +421,7 @@ class Float < Numeric
|
|
|
421
421
|
#
|
|
422
422
|
# Returns:
|
|
423
423
|
#
|
|
424
|
-
# *
|
|
424
|
+
# * <code>-1</code>, if `self` is less than `other`.
|
|
425
425
|
# * `0`, if `self` is equal to `other`.
|
|
426
426
|
# * `1`, if `self` is greater than `other`.
|
|
427
427
|
# * `nil`, if the two values are incommensurate.
|
|
@@ -436,7 +436,8 @@ class Float < Numeric
|
|
|
436
436
|
# 2.0 <=> 1.9 # => 1
|
|
437
437
|
# 2.0 <=> 'foo' # => nil
|
|
438
438
|
#
|
|
439
|
-
#
|
|
439
|
+
# <code>Float::NAN <=> Float::NAN</code> returns an implementation-dependent
|
|
440
|
+
# value.
|
|
440
441
|
#
|
|
441
442
|
# Class Float includes module Comparable, each of whose methods uses Float#<=>
|
|
442
443
|
# for comparison.
|
|
@@ -454,7 +455,8 @@ class Float < Numeric
|
|
|
454
455
|
# 2.0 == Rational(2, 1) # => true
|
|
455
456
|
# 2.0 == Complex(2, 0) # => true
|
|
456
457
|
#
|
|
457
|
-
#
|
|
458
|
+
# <code>Float::NAN == Float::NAN</code> returns an implementation-dependent
|
|
459
|
+
# value.
|
|
458
460
|
#
|
|
459
461
|
# Related: Float#eql? (requires `other` to be a Float).
|
|
460
462
|
#
|
|
@@ -468,7 +470,8 @@ class Float < Numeric
|
|
|
468
470
|
# 2.0 == Rational(2, 1) # => true
|
|
469
471
|
# 2.0 == Complex(2, 0) # => true
|
|
470
472
|
#
|
|
471
|
-
#
|
|
473
|
+
# <code>Float::NAN == Float::NAN</code> returns an implementation-dependent
|
|
474
|
+
# value.
|
|
472
475
|
#
|
|
473
476
|
# Related: Float#eql? (requires `other` to be a Float).
|
|
474
477
|
#
|
|
@@ -485,7 +488,8 @@ class Float < Numeric
|
|
|
485
488
|
# 2.0 > Rational(1, 2) # => true
|
|
486
489
|
# 2.0 > 2.0 # => false
|
|
487
490
|
#
|
|
488
|
-
#
|
|
491
|
+
# <code>Float::NAN > Float::NAN</code> returns an implementation-dependent
|
|
492
|
+
# value.
|
|
489
493
|
#
|
|
490
494
|
def >: (Numeric) -> bool
|
|
491
495
|
|
|
@@ -501,7 +505,8 @@ class Float < Numeric
|
|
|
501
505
|
# 2.0 >= 2.0 # => true
|
|
502
506
|
# 2.0 >= 2.1 # => false
|
|
503
507
|
#
|
|
504
|
-
#
|
|
508
|
+
# <code>Float::NAN >= Float::NAN</code> returns an implementation-dependent
|
|
509
|
+
# value.
|
|
505
510
|
#
|
|
506
511
|
def >=: (Numeric) -> bool
|
|
507
512
|
|
|
@@ -517,12 +522,10 @@ class Float < Numeric
|
|
|
517
522
|
#
|
|
518
523
|
def abs: () -> Float
|
|
519
524
|
|
|
520
|
-
def abs2: () -> Float
|
|
521
|
-
|
|
522
525
|
# <!-- rdoc-file=complex.c -->
|
|
523
526
|
# Returns 0 if `self` is positive, Math::PI otherwise.
|
|
524
527
|
#
|
|
525
|
-
def angle:
|
|
528
|
+
def angle: ...
|
|
526
529
|
|
|
527
530
|
# <!--
|
|
528
531
|
# rdoc-file=complex.c
|
|
@@ -558,7 +561,7 @@ class Float < Numeric
|
|
|
558
561
|
#
|
|
559
562
|
# When `ndigits` is non-positive,
|
|
560
563
|
# returns an Integer based on a computed granularity:
|
|
561
|
-
# * The granularity is
|
|
564
|
+
# * The granularity is <code>10 ** ndigits.abs</code>.
|
|
562
565
|
# * The returned value is the largest multiple of the granularity
|
|
563
566
|
# that is less than or equal to `self`.
|
|
564
567
|
# Examples with positive `self`:
|
|
@@ -610,10 +613,6 @@ class Float < Numeric
|
|
|
610
613
|
#
|
|
611
614
|
def coerce: (Numeric) -> [ Float, Float ]
|
|
612
615
|
|
|
613
|
-
def conj: () -> Float
|
|
614
|
-
|
|
615
|
-
def conjugate: () -> Float
|
|
616
|
-
|
|
617
616
|
# <!--
|
|
618
617
|
# rdoc-file=rational.c
|
|
619
618
|
# - flo.denominator -> integer
|
|
@@ -624,13 +623,11 @@ class Float < Numeric
|
|
|
624
623
|
#
|
|
625
624
|
def denominator: () -> Integer
|
|
626
625
|
|
|
627
|
-
def div: (Numeric) -> Integer
|
|
628
|
-
|
|
629
626
|
# <!--
|
|
630
627
|
# rdoc-file=numeric.c
|
|
631
628
|
# - divmod(other) -> array
|
|
632
629
|
# -->
|
|
633
|
-
# Returns a 2-element array
|
|
630
|
+
# Returns a 2-element array <code>[q, r]</code>, where
|
|
634
631
|
#
|
|
635
632
|
# q = (self/other).floor # Quotient
|
|
636
633
|
# r = self % other # Remainder
|
|
@@ -653,8 +650,6 @@ class Float < Numeric
|
|
|
653
650
|
def divmod: (Integer | Float | Rational) -> [ Integer, Float ]
|
|
654
651
|
| (Numeric) -> [ Numeric, Numeric ]
|
|
655
652
|
|
|
656
|
-
def dup: () -> self
|
|
657
|
-
|
|
658
653
|
# <!--
|
|
659
654
|
# rdoc-file=numeric.c
|
|
660
655
|
# - eql?(other) -> true or false
|
|
@@ -668,7 +663,8 @@ class Float < Numeric
|
|
|
668
663
|
# 2.0.eql?(Rational(2, 1)) # => false
|
|
669
664
|
# 2.0.eql?(Complex(2, 0)) # => false
|
|
670
665
|
#
|
|
671
|
-
#
|
|
666
|
+
# <code>Float::NAN.eql?(Float::NAN)</code> returns an implementation-dependent
|
|
667
|
+
# value.
|
|
672
668
|
#
|
|
673
669
|
# Related: Float#== (performs type conversions).
|
|
674
670
|
#
|
|
@@ -690,8 +686,8 @@ class Float < Numeric
|
|
|
690
686
|
# rdoc-file=numeric.c
|
|
691
687
|
# - finite? -> true or false
|
|
692
688
|
# -->
|
|
693
|
-
# Returns `true` if `self` is not `Infinity`,
|
|
694
|
-
# otherwise:
|
|
689
|
+
# Returns `true` if `self` is not `Infinity`, <code>-Infinity</code>, or `NaN`,
|
|
690
|
+
# `false` otherwise:
|
|
695
691
|
#
|
|
696
692
|
# f = 2.0 # => 2.0
|
|
697
693
|
# f.finite? # => true
|
|
@@ -736,7 +732,7 @@ class Float < Numeric
|
|
|
736
732
|
#
|
|
737
733
|
# When `self` is non-zero and `ndigits` is non-positive,
|
|
738
734
|
# returns an integer value based on a computed granularity:
|
|
739
|
-
# * The granularity is
|
|
735
|
+
# * The granularity is <code>10 ** ndigits.abs</code>.
|
|
740
736
|
# * The returned value is the largest multiple of the granularity
|
|
741
737
|
# that is less than or equal to `self`.
|
|
742
738
|
# Examples with positive `self`:
|
|
@@ -777,12 +773,6 @@ class Float < Numeric
|
|
|
777
773
|
#
|
|
778
774
|
def hash: () -> Integer
|
|
779
775
|
|
|
780
|
-
def i: () -> Complex
|
|
781
|
-
|
|
782
|
-
def imag: () -> Integer
|
|
783
|
-
|
|
784
|
-
def imaginary: () -> Integer
|
|
785
|
-
|
|
786
776
|
# <!--
|
|
787
777
|
# rdoc-file=numeric.c
|
|
788
778
|
# - infinite? -> -1, 1, or nil
|
|
@@ -790,7 +780,7 @@ class Float < Numeric
|
|
|
790
780
|
# Returns:
|
|
791
781
|
#
|
|
792
782
|
# * 1, if `self` is `Infinity`.
|
|
793
|
-
# * -1 if `self` is
|
|
783
|
+
# * -1 if `self` is <code>-Infinity</code>.
|
|
794
784
|
# * `nil`, otherwise.
|
|
795
785
|
#
|
|
796
786
|
# Examples:
|
|
@@ -827,8 +817,6 @@ class Float < Numeric
|
|
|
827
817
|
#
|
|
828
818
|
alias inspect to_s
|
|
829
819
|
|
|
830
|
-
def integer?: () -> bool
|
|
831
|
-
|
|
832
820
|
# <!--
|
|
833
821
|
# rdoc-file=numeric.rb
|
|
834
822
|
# - magnitude()
|
|
@@ -890,7 +878,7 @@ class Float < Numeric
|
|
|
890
878
|
# Returns the next-larger representable Float.
|
|
891
879
|
#
|
|
892
880
|
# These examples show the internally stored values (64-bit hexadecimal) for each
|
|
893
|
-
# Float `f` and for the corresponding
|
|
881
|
+
# Float `f` and for the corresponding <code>f.next_float</code>:
|
|
894
882
|
#
|
|
895
883
|
# f = 0.0 # 0x0000000000000000
|
|
896
884
|
# f.next_float # 0x0000000000000001
|
|
@@ -928,8 +916,6 @@ class Float < Numeric
|
|
|
928
916
|
#
|
|
929
917
|
def next_float: () -> Float
|
|
930
918
|
|
|
931
|
-
def nonzero?: () -> self?
|
|
932
|
-
|
|
933
919
|
# <!--
|
|
934
920
|
# rdoc-file=rational.c
|
|
935
921
|
# - flo.numerator -> integer
|
|
@@ -966,7 +952,7 @@ class Float < Numeric
|
|
|
966
952
|
# Returns the next-smaller representable Float.
|
|
967
953
|
#
|
|
968
954
|
# These examples show the internally stored values (64-bit hexadecimal) for each
|
|
969
|
-
# Float `f` and for the corresponding
|
|
955
|
+
# Float `f` and for the corresponding <code>f.pev_float</code>:
|
|
970
956
|
#
|
|
971
957
|
# f = 5e-324 # 0x0000000000000001
|
|
972
958
|
# f.prev_float # 0x0000000000000000
|
|
@@ -1026,14 +1012,8 @@ class Float < Numeric
|
|
|
1026
1012
|
#
|
|
1027
1013
|
def rationalize: (?Numeric eps) -> Rational
|
|
1028
1014
|
|
|
1029
|
-
def real: () -> Float
|
|
1030
|
-
|
|
1031
|
-
def real?: () -> true
|
|
1032
|
-
|
|
1033
1015
|
def rect: () -> [ Float, Numeric ]
|
|
1034
1016
|
|
|
1035
|
-
alias rectangular rect
|
|
1036
|
-
|
|
1037
1017
|
def remainder: (Numeric) -> Float
|
|
1038
1018
|
|
|
1039
1019
|
# <!--
|
|
@@ -1053,8 +1033,8 @@ class Float < Numeric
|
|
|
1053
1033
|
# f.round(1) # => -12345.7
|
|
1054
1034
|
# f.round(3) # => -12345.679
|
|
1055
1035
|
#
|
|
1056
|
-
# When `ndigits` is negative, returns an integer with at least
|
|
1057
|
-
# trailing zeros:
|
|
1036
|
+
# When `ndigits` is negative, returns an integer with at least
|
|
1037
|
+
# <code>ndigits.abs</code> trailing zeros:
|
|
1058
1038
|
#
|
|
1059
1039
|
# f = 12345.6789
|
|
1060
1040
|
# f.round(0) # => 12346
|
|
@@ -1066,19 +1046,20 @@ class Float < Numeric
|
|
|
1066
1046
|
# If keyword argument `half` is given, and `self` is equidistant from the two
|
|
1067
1047
|
# candidate values, the rounding is according to the given `half` value:
|
|
1068
1048
|
#
|
|
1069
|
-
# *
|
|
1049
|
+
# * <code>:up</code> or `nil`: round away from zero:
|
|
1070
1050
|
#
|
|
1071
1051
|
# 2.5.round(half: :up) # => 3
|
|
1072
1052
|
# 3.5.round(half: :up) # => 4
|
|
1073
1053
|
# (-2.5).round(half: :up) # => -3
|
|
1074
1054
|
#
|
|
1075
|
-
# *
|
|
1055
|
+
# * <code>:down</code>: round toward zero:
|
|
1076
1056
|
#
|
|
1077
1057
|
# 2.5.round(half: :down) # => 2
|
|
1078
1058
|
# 3.5.round(half: :down) # => 3
|
|
1079
1059
|
# (-2.5).round(half: :down) # => -2
|
|
1080
1060
|
#
|
|
1081
|
-
# *
|
|
1061
|
+
# * <code>:even</code>: round toward the candidate whose last nonzero digit is
|
|
1062
|
+
# even:
|
|
1082
1063
|
#
|
|
1083
1064
|
# 2.5.round(half: :even) # => 2
|
|
1084
1065
|
# 3.5.round(half: :even) # => 4
|
|
@@ -1091,13 +1072,6 @@ class Float < Numeric
|
|
|
1091
1072
|
def round: (?half: :up | :down | :even) -> Integer
|
|
1092
1073
|
| (int digits, ?half: :up | :down | :even) -> (Integer | Float)
|
|
1093
1074
|
|
|
1094
|
-
def step: (?Numeric limit, ?Numeric step) { (Float) -> void } -> self
|
|
1095
|
-
| (?Numeric limit, ?Numeric step) -> Enumerator[Float, self]
|
|
1096
|
-
| (?by: Numeric, ?to: Numeric) { (Float) -> void } -> self
|
|
1097
|
-
| (?by: Numeric, ?to: Numeric) -> Enumerator[Float, self]
|
|
1098
|
-
|
|
1099
|
-
def to_c: () -> Complex
|
|
1100
|
-
|
|
1101
1075
|
# <!--
|
|
1102
1076
|
# rdoc-file=numeric.rb
|
|
1103
1077
|
# - to_f -> self
|
|
@@ -1198,8 +1172,8 @@ class Float < Numeric
|
|
|
1198
1172
|
# f.truncate(1) # => -12345.6
|
|
1199
1173
|
# f.truncate(3) # => -12345.678
|
|
1200
1174
|
#
|
|
1201
|
-
# When `ndigits` is negative, returns an integer with at least
|
|
1202
|
-
# trailing zeros:
|
|
1175
|
+
# When `ndigits` is negative, returns an integer with at least
|
|
1176
|
+
# <code>ndigits.abs</code> trailing zeros:
|
|
1203
1177
|
#
|
|
1204
1178
|
# f = 12345.6789
|
|
1205
1179
|
# f.truncate(0) # => 12345
|
|
@@ -1285,8 +1259,8 @@ Float::MAX_EXP: Integer
|
|
|
1285
1259
|
# Usually defaults to 2.2250738585072014e-308.
|
|
1286
1260
|
#
|
|
1287
1261
|
# If the platform supports denormalized numbers, there are numbers between zero
|
|
1288
|
-
# and Float::MIN.
|
|
1289
|
-
# number including denormalized numbers.
|
|
1262
|
+
# and Float::MIN. <code>0.0.next_float</code> returns the smallest positive
|
|
1263
|
+
# floating point number including denormalized numbers.
|
|
1290
1264
|
#
|
|
1291
1265
|
Float::MIN: Float
|
|
1292
1266
|
|
data/core/gc.rbs
CHANGED
|
@@ -182,21 +182,21 @@ module GC
|
|
|
182
182
|
# GC.config(foo: 'bar')
|
|
183
183
|
# # => {rgengc_allow_full_mark: false, implementation: "default"}
|
|
184
184
|
#
|
|
185
|
-
#
|
|
185
|
+
# <strong>All-Implementations Configuration</strong>
|
|
186
186
|
#
|
|
187
187
|
# The single read-only entry for all implementations is:
|
|
188
188
|
#
|
|
189
|
-
# *
|
|
190
|
-
# default implementation,
|
|
189
|
+
# * <code>:implementation</code>: the string name of the implementation; for
|
|
190
|
+
# the Ruby default implementation, <code>'default'</code>.
|
|
191
191
|
#
|
|
192
|
-
#
|
|
192
|
+
# <strong>Implementation-Specific Configuration</strong>
|
|
193
193
|
#
|
|
194
194
|
# A GC implementation maintains its own implementation-specific configuration.
|
|
195
195
|
#
|
|
196
196
|
# For Ruby's default implementation the single entry is:
|
|
197
197
|
#
|
|
198
|
-
# *
|
|
199
|
-
# full mark (young & old objects):
|
|
198
|
+
# * <code>:rgengc_allow_full_mark</code>: Controls whether the GC is allowed
|
|
199
|
+
# to run a full mark (young & old objects):
|
|
200
200
|
#
|
|
201
201
|
# * `true` (default): GC interleaves major and minor collections. A flag
|
|
202
202
|
# is set to notify GC that a full mark has been requested. This flag is
|
|
@@ -348,59 +348,66 @@ module GC
|
|
|
348
348
|
#
|
|
349
349
|
# The hash includes entries such as:
|
|
350
350
|
#
|
|
351
|
-
# *
|
|
352
|
-
# start (count includes both minor and major garbage
|
|
353
|
-
#
|
|
354
|
-
# *
|
|
355
|
-
#
|
|
356
|
-
#
|
|
357
|
-
# *
|
|
358
|
-
# that
|
|
359
|
-
# *
|
|
360
|
-
#
|
|
361
|
-
# *
|
|
362
|
-
#
|
|
363
|
-
# *
|
|
364
|
-
#
|
|
365
|
-
#
|
|
366
|
-
#
|
|
367
|
-
#
|
|
368
|
-
#
|
|
369
|
-
# *
|
|
370
|
-
#
|
|
371
|
-
# *
|
|
372
|
-
#
|
|
373
|
-
# *
|
|
374
|
-
#
|
|
375
|
-
# *
|
|
351
|
+
# * <code>:count</code>: The total number of garbage collections run since
|
|
352
|
+
# application start (count includes both minor and major garbage
|
|
353
|
+
# collections).
|
|
354
|
+
# * <code>:time</code>: The total time spent in garbage collections (in
|
|
355
|
+
# milliseconds).
|
|
356
|
+
# * <code>:heap_allocated_pages</code>: The total number of allocated pages.
|
|
357
|
+
# * <code>:heap_empty_pages</code>: The number of pages with no live objects,
|
|
358
|
+
# and that could be released to the system.
|
|
359
|
+
# * <code>:heap_sorted_length</code>: The number of pages that can fit into
|
|
360
|
+
# the buffer that holds references to all pages.
|
|
361
|
+
# * <code>:heap_allocatable_pages</code>: The total number of pages the
|
|
362
|
+
# application could allocate without additional GC.
|
|
363
|
+
# * <code>:heap_available_slots</code>: The total number of slots in all
|
|
364
|
+
# <code>:heap_allocated_pages</code>.
|
|
365
|
+
# * <code>:heap_live_slots</code>: The total number of slots which contain
|
|
366
|
+
# live objects.
|
|
367
|
+
# * <code>:heap_free_slots</code>: The total number of slots which do not
|
|
368
|
+
# contain live objects.
|
|
369
|
+
# * <code>:heap_final_slots</code>: The total number of slots with pending
|
|
370
|
+
# finalizers to be run.
|
|
371
|
+
# * <code>:heap_marked_slots</code>: The total number of objects marked in the
|
|
372
|
+
# last GC.
|
|
373
|
+
# * <code>:heap_eden_pages</code>: The total number of pages which contain at
|
|
374
|
+
# least one live slot.
|
|
375
|
+
# * <code>:total_allocated_pages</code>: The cumulative number of pages
|
|
376
|
+
# allocated since application start.
|
|
377
|
+
# * <code>:total_freed_pages</code>: The cumulative number of pages freed
|
|
376
378
|
# since application start.
|
|
377
|
-
# *
|
|
378
|
-
# application start.
|
|
379
|
-
# *
|
|
380
|
-
#
|
|
381
|
-
# *
|
|
382
|
-
#
|
|
383
|
-
# *
|
|
384
|
-
#
|
|
385
|
-
# *
|
|
379
|
+
# * <code>:total_allocated_objects</code>: The cumulative number of objects
|
|
380
|
+
# allocated since application start.
|
|
381
|
+
# * <code>:total_freed_objects</code>: The cumulative number of objects freed
|
|
382
|
+
# since application start.
|
|
383
|
+
# * <code>:malloc_increase_bytes</code>: Amount of memory allocated on the
|
|
384
|
+
# heap for objects. Decreased by any GC.
|
|
385
|
+
# * <code>:malloc_increase_bytes_limit</code>: When
|
|
386
|
+
# <code>:malloc_increase_bytes</code> crosses this limit, GC is triggered.
|
|
387
|
+
# * <code>:minor_gc_count</code>: The total number of minor garbage
|
|
388
|
+
# collections run since process start.
|
|
389
|
+
# * <code>:major_gc_count</code>: The total number of major garbage
|
|
390
|
+
# collections run since process start.
|
|
391
|
+
# * <code>:compact_count</code>: The total number of compactions run since
|
|
386
392
|
# process start.
|
|
387
|
-
# *
|
|
388
|
-
#
|
|
389
|
-
#
|
|
390
|
-
#
|
|
391
|
-
# *
|
|
392
|
-
# write barriers.
|
|
393
|
-
# *
|
|
394
|
-
#
|
|
395
|
-
# triggered.
|
|
396
|
-
# *
|
|
397
|
-
# garbage collections.
|
|
398
|
-
# *
|
|
393
|
+
# * <code>:read_barrier_faults</code>: The total number of times the read
|
|
394
|
+
# barrier was triggered during compaction.
|
|
395
|
+
# * <code>:total_moved_objects</code>: The total number of objects compaction
|
|
396
|
+
# has moved.
|
|
397
|
+
# * <code>:remembered_wb_unprotected_objects</code>: The total number of
|
|
398
|
+
# objects without write barriers.
|
|
399
|
+
# * <code>:remembered_wb_unprotected_objects_limit</code>: When
|
|
400
|
+
# <code>:remembered_wb_unprotected_objects</code> crosses this limit, major
|
|
401
|
+
# GC is triggered.
|
|
402
|
+
# * <code>:old_objects</code>: Number of live, old objects which have survived
|
|
403
|
+
# at least 3 garbage collections.
|
|
404
|
+
# * <code>:old_objects_limit</code>: When <code>:old_objects</code> crosses
|
|
405
|
+
# this limit, major GC is triggered.
|
|
406
|
+
# * <code>:oldmalloc_increase_bytes</code>: Amount of memory allocated on the
|
|
407
|
+
# heap for objects. Decreased by major GC.
|
|
408
|
+
# * <code>:oldmalloc_increase_bytes_limit</code>: When
|
|
409
|
+
# <code>:oldmalloc_increase_bytes</code> crosses this limit, major GC is
|
|
399
410
|
# triggered.
|
|
400
|
-
# * `:oldmalloc_increase_bytes`: Amount of memory allocated on the heap for
|
|
401
|
-
# objects. Decreased by major GC.
|
|
402
|
-
# * `:oldmalloc_increase_bytes_limit`: When `:oldmalloc_increase_bytes`
|
|
403
|
-
# crosses this limit, major GC is triggered.
|
|
404
411
|
#
|
|
405
412
|
def self.stat: (?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
406
413
|
| (Symbol key) -> Integer
|
|
@@ -575,21 +582,22 @@ module GC
|
|
|
575
582
|
#
|
|
576
583
|
# The statistics for a heap may include:
|
|
577
584
|
#
|
|
578
|
-
# *
|
|
579
|
-
# *
|
|
580
|
-
# without triggering a new garbage collection cycle.
|
|
581
|
-
# *
|
|
582
|
-
# *
|
|
583
|
-
# eden heap.
|
|
584
|
-
# *
|
|
585
|
-
# allocated in the heap.
|
|
586
|
-
# *
|
|
587
|
-
# released back to the system in the heap.
|
|
588
|
-
# *
|
|
589
|
-
# garbage collection cycles to start due to running out of free
|
|
590
|
-
# * `:force_incremental_marking_finish_count`: The number of times this heap
|
|
591
|
-
# has forced incremental marking to complete due to running out of pooled
|
|
585
|
+
# * <code>:slot_size</code>: The slot size of the heap in bytes.
|
|
586
|
+
# * <code>:heap_allocatable_pages</code>: The number of pages that can be
|
|
587
|
+
# allocated without triggering a new garbage collection cycle.
|
|
588
|
+
# * <code>:heap_eden_pages</code>: The number of pages in the eden heap.
|
|
589
|
+
# * <code>:heap_eden_slots</code>: The total number of slots in all of the
|
|
590
|
+
# pages in the eden heap.
|
|
591
|
+
# * <code>:total_allocated_pages</code>: The total number of pages that have
|
|
592
|
+
# been allocated in the heap.
|
|
593
|
+
# * <code>:total_freed_pages</code>: The total number of pages that have been
|
|
594
|
+
# freed and released back to the system in the heap.
|
|
595
|
+
# * <code>:force_major_gc_count</code>: The number of times this heap has
|
|
596
|
+
# forced major garbage collection cycles to start due to running out of free
|
|
592
597
|
# slots.
|
|
598
|
+
# * <code>:force_incremental_marking_finish_count</code>: The number of times
|
|
599
|
+
# this heap has forced incremental marking to complete due to running out of
|
|
600
|
+
# pooled slots.
|
|
593
601
|
#
|
|
594
602
|
def self.stat_heap: (?Integer? heap_name, ?Hash[Symbol, untyped]? hash) -> Hash[Symbol, untyped]
|
|
595
603
|
| (Integer heap_name, Symbol key) -> Integer
|