rbs 3.10.0.pre.2 → 3.10.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/c-check.yml +1 -1
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/ruby.yml +7 -8
- data/CHANGELOG.md +60 -0
- data/core/array.rbs +52 -3
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +40 -25
- data/core/dir.rbs +2 -2
- data/core/encoding.rbs +3 -7
- data/core/enumerable.rbs +1 -1
- data/core/enumerator.rbs +43 -1
- data/core/fiber.rbs +26 -17
- data/core/file.rbs +23 -8
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +223 -32
- data/core/gc.rbs +4 -9
- data/core/hash.rbs +9 -10
- data/core/integer.rbs +104 -63
- data/core/io/buffer.rbs +21 -10
- data/core/io.rbs +8 -8
- data/core/kernel.rbs +12 -8
- data/core/method.rbs +49 -19
- data/core/module.rbs +30 -12
- data/core/numeric.rbs +17 -9
- data/core/object_space.rbs +13 -20
- data/core/pathname.rbs +2 -37
- data/core/proc.rbs +15 -16
- data/core/ractor.rbs +156 -145
- data/core/range.rbs +1 -1
- data/core/rational.rbs +56 -34
- data/core/rbs/unnamed/argf.rbs +1 -1
- data/core/regexp.rbs +3 -3
- data/core/ruby.rbs +53 -0
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +88 -66
- data/core/signal.rbs +24 -14
- data/core/string.rbs +304 -166
- data/core/symbol.rbs +13 -7
- data/core/thread.rbs +12 -13
- data/core/trace_point.rbs +7 -4
- data/lib/rbs/collection/config/lockfile_generator.rb +7 -0
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +1 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- 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 +11 -1
- data/stdlib/cgi-escape/0/escape.rbs +33 -15
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/json/0/json.rbs +1 -0
- data/stdlib/objspace/0/objspace.rbs +1 -1
- data/stdlib/openssl/0/openssl.rbs +150 -80
- data/stdlib/pathname/0/pathname.rbs +36 -0
- data/stdlib/psych/0/psych.rbs +3 -3
- data/stdlib/stringio/0/stringio.rbs +796 -37
- data/stdlib/strscan/0/string_scanner.rbs +1 -1
- data/stdlib/tempfile/0/tempfile.rbs +2 -2
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/uri/0/generic.rbs +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0e199e19fdc063a93575bc59d1daff68480bc7c678e0b9a00a20bd882c0167f
|
|
4
|
+
data.tar.gz: 42415916b4eebb2b739ce009088fd8fcec8c02a8ad0c4169ccf57dd9b69bba79
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9ba79e77d4f6ca3b57f6a89e245e20edd6ceba274475ad435a4bfb45e78dc17e4ab3ca033b208279b4ee1bef0498d82459ef912bbc2dfcabb16c921f4802e72
|
|
7
|
+
data.tar.gz: 8c8100da156288e99931d15f0a3e61439a08d51e3d85605f95770d62cdfc4e1fd3cc71ede93763ce08e480084ed8301a26b781db3988b7fc931ea727fccd7e29
|
|
@@ -10,13 +10,13 @@ on:
|
|
|
10
10
|
jobs:
|
|
11
11
|
comments:
|
|
12
12
|
runs-on: "ubuntu-latest"
|
|
13
|
-
env:
|
|
14
|
-
|
|
13
|
+
# env:
|
|
14
|
+
# RUBY_COMMIT: v4.0.0-preview2
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions/checkout@v4
|
|
17
17
|
- uses: ruby/setup-ruby@v1
|
|
18
18
|
with:
|
|
19
|
-
ruby-version: "4.0.0
|
|
19
|
+
ruby-version: "4.0.0"
|
|
20
20
|
bundler: none
|
|
21
21
|
- name: Install dependencies
|
|
22
22
|
run: |
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -13,24 +13,24 @@ jobs:
|
|
|
13
13
|
strategy:
|
|
14
14
|
fail-fast: false
|
|
15
15
|
matrix:
|
|
16
|
-
ruby: ['3.2', '3.3', '3.4', '4.0
|
|
16
|
+
ruby: ['3.2', '3.3', '3.4', '4.0', head]
|
|
17
17
|
rubyopt: [""]
|
|
18
18
|
job:
|
|
19
19
|
- test
|
|
20
20
|
include:
|
|
21
21
|
- ruby: head
|
|
22
22
|
job: stdlib_test rubocop
|
|
23
|
-
- ruby: "4.0
|
|
23
|
+
- ruby: "4.0"
|
|
24
24
|
job: stdlib_test
|
|
25
|
-
- ruby: "4.0
|
|
25
|
+
- ruby: "4.0"
|
|
26
26
|
job: test
|
|
27
27
|
rubyopt: "--enable-frozen-string-literal"
|
|
28
|
-
- ruby: "4.0
|
|
28
|
+
- ruby: "4.0"
|
|
29
29
|
job: stdlib_test
|
|
30
30
|
rubyopt: "--enable-frozen-string-literal"
|
|
31
|
-
- ruby: "4.0
|
|
31
|
+
- ruby: "4.0"
|
|
32
32
|
job: rubocop validate test_doc build test_generate_stdlib raap
|
|
33
|
-
- ruby: "4.0
|
|
33
|
+
- ruby: "4.0"
|
|
34
34
|
job: typecheck_test
|
|
35
35
|
env:
|
|
36
36
|
RANDOMIZE_STDLIB_TEST_ORDER: "true"
|
|
@@ -94,7 +94,7 @@ jobs:
|
|
|
94
94
|
strategy:
|
|
95
95
|
fail-fast: false
|
|
96
96
|
matrix:
|
|
97
|
-
ruby: ['4.0
|
|
97
|
+
ruby: ['4.0', head]
|
|
98
98
|
steps:
|
|
99
99
|
- uses: actions/checkout@v4
|
|
100
100
|
- name: Install dependencies
|
|
@@ -116,4 +116,3 @@ jobs:
|
|
|
116
116
|
run: |
|
|
117
117
|
bin/setup
|
|
118
118
|
- run: bundle exec rake clean compile_c99
|
|
119
|
-
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 3.10.1 (2026-01-07)
|
|
4
|
+
|
|
5
|
+
This is a follow-up release for Ruby 4.0.0 with documentation update based on Ruby 4.0.0, and bugfixes related to set/pathname library loading.
|
|
6
|
+
|
|
7
|
+
### Pull Requests
|
|
8
|
+
|
|
9
|
+
* Merge pull request #2777 from ksss/pathname-ext ([#2786](https://github.com/ruby/rbs/pull/2786))
|
|
10
|
+
* Ruby 4.0.0 backports ([#2785](https://github.com/ruby/rbs/pull/2785))
|
|
11
|
+
* [Backport] Fix subtraction of civar ([#2783](https://github.com/ruby/rbs/pull/2783))
|
|
12
|
+
* [Backport] Update ruby to 4.0 ([#2778](https://github.com/ruby/rbs/pull/2778))
|
|
13
|
+
|
|
14
|
+
## 3.10.0 (2025-12-23)
|
|
15
|
+
|
|
16
|
+
RBS 3.10.0 ships with a pure C parser implementation, signature updates for Ruby 4.0, and various bug fixes.
|
|
17
|
+
|
|
18
|
+
### Pure C parser implementation
|
|
19
|
+
|
|
20
|
+
The new parser implementation was announced at [RubyKaigi 2025](https://rubykaigi.org/2025/presentations/amomchilov.html) and is finally shipped as a RubyGem!
|
|
21
|
+
|
|
22
|
+
The new parser is faster than the one in 3.9 and is portable — it is independent of the Ruby runtime and is used to implement Sorbet’s RBS support.
|
|
23
|
+
|
|
24
|
+
### Type definition of bundled gems
|
|
25
|
+
|
|
26
|
+
The type definitions of `cgi` have been moved to [gem_rbs_collection](https://github.com/ruby/gem_rbs_collection/tree/main/gems/cgi), as it has been migrated to a bundled gem in Ruby 4.0
|
|
27
|
+
|
|
28
|
+
`cgi-escape` has been added to `stdlib`. You may need to declare a dependency on `cgi-escape` in your `manifest.yaml`, add `-r cgi-escape` to your command line, or update your type checker configuration.
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
dependencies:
|
|
32
|
+
- name: cgi-escape
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The type definitions for `pathname` have also been moved from `stdlib` to `core`, as it is now implemented as part of the core library.
|
|
36
|
+
|
|
37
|
+
### Pull Requests
|
|
38
|
+
|
|
39
|
+
* [Backport] Support rdoc v7 ([#2770](https://github.com/ruby/rbs/pull/2770))
|
|
40
|
+
* [Backport] Check tuple type length ([#2766](https://github.com/ruby/rbs/pull/2766))
|
|
41
|
+
* Backport update to 4.0.0-preview3 ([#2768](https://github.com/ruby/rbs/pull/2768))
|
|
42
|
+
* [Backport] Remove test code for bundled gems ([#2762](https://github.com/ruby/rbs/pull/2762))
|
|
43
|
+
* Merge pull request #2761 from ruby/update-minitest ([#2763](https://github.com/ruby/rbs/pull/2763))
|
|
44
|
+
* [Backport] Support BigDecimal v4 ([#2759](https://github.com/ruby/rbs/pull/2759))
|
|
45
|
+
* Parser/lexer backports ([#2756](https://github.com/ruby/rbs/pull/2756))
|
|
46
|
+
* Merge pull request #2753 from ruby/delete-printf ([#2754](https://github.com/ruby/rbs/pull/2754))
|
|
47
|
+
* Backports ([#2751](https://github.com/ruby/rbs/pull/2751))
|
|
48
|
+
* Merge pull request #2728 from ruby/cgi ([#2747](https://github.com/ruby/rbs/pull/2747))
|
|
49
|
+
* Merge pull request #2729 from ruby/rbs-assert ([#2748](https://github.com/ruby/rbs/pull/2748))
|
|
50
|
+
* Merge pull request #2749 from ruby/fix-test ([#2750](https://github.com/ruby/rbs/pull/2750))
|
|
51
|
+
* Backport RBS file updates ([#2742](https://github.com/ruby/rbs/pull/2742))
|
|
52
|
+
* Backport JSON PRs ([#2740](https://github.com/ruby/rbs/pull/2740))
|
|
53
|
+
* Merge pull request #2718 from ruby/ruby-4 ([#2741](https://github.com/ruby/rbs/pull/2741))
|
|
54
|
+
* [Backport] Move Pathname to core from stdlib ([#2730](https://github.com/ruby/rbs/pull/2730))
|
|
55
|
+
* Backport rdoc 6.16 ([#2722](https://github.com/ruby/rbs/pull/2722))
|
|
56
|
+
* Backport rdoc support ([#2719](https://github.com/ruby/rbs/pull/2719))
|
|
57
|
+
* Backport "Remove sig for IO#{ready?,nread}" ([#2720](https://github.com/ruby/rbs/pull/2720))
|
|
58
|
+
* Backport more pure C parsers ([#2679](https://github.com/ruby/rbs/pull/2679))
|
|
59
|
+
* Backport module name normalization ([#2673](https://github.com/ruby/rbs/pull/2673))
|
|
60
|
+
* Backport pure-C parser ([#2671](https://github.com/ruby/rbs/pull/2671))
|
|
61
|
+
* Fix test failure ([#2672](https://github.com/ruby/rbs/pull/2672))
|
|
62
|
+
|
|
3
63
|
## 3.9.5 (2025-09-08)
|
|
4
64
|
|
|
5
65
|
### Signature updates
|
data/core/array.rbs
CHANGED
|
@@ -1213,7 +1213,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1213
1213
|
# Returns the element from `self` found by a binary search, or `nil` if the
|
|
1214
1214
|
# search found no suitable element.
|
|
1215
1215
|
#
|
|
1216
|
-
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
|
|
1216
|
+
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
|
|
1217
1217
|
#
|
|
1218
1218
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1219
1219
|
#
|
|
@@ -1229,7 +1229,7 @@ class Array[unchecked out Elem] < Object
|
|
|
1229
1229
|
# Returns the integer index of the element from `self` found by a binary search,
|
|
1230
1230
|
# or `nil` if the search found no suitable element.
|
|
1231
1231
|
#
|
|
1232
|
-
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
|
|
1232
|
+
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
|
|
1233
1233
|
#
|
|
1234
1234
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1235
1235
|
#
|
|
@@ -2019,6 +2019,30 @@ class Array[unchecked out Elem] < Object
|
|
|
2019
2019
|
def filter!: () { (Elem item) -> boolish } -> self?
|
|
2020
2020
|
| () -> ::Enumerator[Elem, self?]
|
|
2021
2021
|
|
|
2022
|
+
# <!--
|
|
2023
|
+
# rdoc-file=array.c
|
|
2024
|
+
# - find(if_none_proc = nil) {|element| ... } -> object or nil
|
|
2025
|
+
# - find(if_none_proc = nil) -> enumerator
|
|
2026
|
+
# -->
|
|
2027
|
+
# Returns the first element for which the block returns a truthy value.
|
|
2028
|
+
#
|
|
2029
|
+
# With a block given, calls the block with successive elements of the array;
|
|
2030
|
+
# returns the first element for which the block returns a truthy value:
|
|
2031
|
+
#
|
|
2032
|
+
# [1, 3, 5].find {|element| element > 2} # => 3
|
|
2033
|
+
#
|
|
2034
|
+
# If no such element is found, calls `if_none_proc` and returns its return
|
|
2035
|
+
# value.
|
|
2036
|
+
#
|
|
2037
|
+
# [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
|
|
2038
|
+
#
|
|
2039
|
+
# With no block given, returns an Enumerator.
|
|
2040
|
+
#
|
|
2041
|
+
def find: () { (Elem) -> boolish } -> Elem?
|
|
2042
|
+
| () -> ::Enumerator[Elem, Elem?]
|
|
2043
|
+
| [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
|
|
2044
|
+
| [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
|
|
2045
|
+
|
|
2022
2046
|
# <!--
|
|
2023
2047
|
# rdoc-file=array.c
|
|
2024
2048
|
# - find_index(object) -> integer or nil
|
|
@@ -2618,7 +2642,7 @@ class Array[unchecked out Elem] < Object
|
|
|
2618
2642
|
# - pack(template, buffer: nil) -> string
|
|
2619
2643
|
# -->
|
|
2620
2644
|
# Formats each element in `self` into a binary string; returns that string. See
|
|
2621
|
-
# [Packed Data](rdoc-ref:packed_data.rdoc).
|
|
2645
|
+
# [Packed Data](rdoc-ref:language/packed_data.rdoc).
|
|
2622
2646
|
#
|
|
2623
2647
|
def pack: (string fmt, ?buffer: String?) -> String
|
|
2624
2648
|
|
|
@@ -2988,6 +3012,31 @@ class Array[unchecked out Elem] < Object
|
|
|
2988
3012
|
def reverse_each: () { (Elem item) -> void } -> self
|
|
2989
3013
|
| () -> ::Enumerator[Elem, self]
|
|
2990
3014
|
|
|
3015
|
+
# <!--
|
|
3016
|
+
# rdoc-file=array.c
|
|
3017
|
+
# - rfind(if_none_proc = nil) {|element| ... } -> object or nil
|
|
3018
|
+
# - rfind(if_none_proc = nil) -> enumerator
|
|
3019
|
+
# -->
|
|
3020
|
+
# Returns the last element for which the block returns a truthy value.
|
|
3021
|
+
#
|
|
3022
|
+
# With a block given, calls the block with successive elements of the array in
|
|
3023
|
+
# reverse order; returns the first element for which the block returns a truthy
|
|
3024
|
+
# value:
|
|
3025
|
+
#
|
|
3026
|
+
# [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4
|
|
3027
|
+
#
|
|
3028
|
+
# If no such element is found, calls `if_none_proc` and returns its return
|
|
3029
|
+
# value.
|
|
3030
|
+
#
|
|
3031
|
+
# [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0
|
|
3032
|
+
#
|
|
3033
|
+
# With no block given, returns an Enumerator.
|
|
3034
|
+
#
|
|
3035
|
+
def rfind: () { (Elem) -> boolish } -> Elem?
|
|
3036
|
+
| () -> ::Enumerator[Elem, Elem?]
|
|
3037
|
+
| [T] (Enumerable::_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
|
|
3038
|
+
| [T] (Enumerable::_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
|
|
3039
|
+
|
|
2991
3040
|
# <!--
|
|
2992
3041
|
# rdoc-file=array.c
|
|
2993
3042
|
# - rindex(object) -> integer or nil
|
data/core/comparable.rbs
CHANGED
|
@@ -55,19 +55,26 @@
|
|
|
55
55
|
module Comparable : _WithSpaceshipOperator
|
|
56
56
|
# <!--
|
|
57
57
|
# rdoc-file=compar.c
|
|
58
|
-
# -
|
|
58
|
+
# - self < other -> true or false
|
|
59
59
|
# -->
|
|
60
|
-
#
|
|
61
|
-
#
|
|
60
|
+
# Returns whether `self` is "less than" `other`; equivalent to `(self <=> other)
|
|
61
|
+
# < 0`:
|
|
62
|
+
#
|
|
63
|
+
# 'foo' < 'foo' # => false
|
|
64
|
+
# 'foo' < 'food' # => true
|
|
62
65
|
#
|
|
63
66
|
def <: (untyped other) -> bool
|
|
64
67
|
|
|
65
68
|
# <!--
|
|
66
69
|
# rdoc-file=compar.c
|
|
67
|
-
# -
|
|
70
|
+
# - self <= other -> true or false
|
|
68
71
|
# -->
|
|
69
|
-
#
|
|
70
|
-
#
|
|
72
|
+
# Returns whether `self` is "less than or equal to" `other`; equivalent to
|
|
73
|
+
# `(self <=> other) <= 0`:
|
|
74
|
+
#
|
|
75
|
+
# 'foo' <= 'foo' # => true
|
|
76
|
+
# 'foo' <= 'food' # => true
|
|
77
|
+
# 'food' <= 'foo' # => false
|
|
71
78
|
#
|
|
72
79
|
def <=: (untyped other) -> bool
|
|
73
80
|
|
data/core/complex.rbs
CHANGED
|
@@ -184,23 +184,24 @@ class Complex < Numeric
|
|
|
184
184
|
|
|
185
185
|
# <!--
|
|
186
186
|
# rdoc-file=complex.c
|
|
187
|
-
# -
|
|
187
|
+
# - self * other -> numeric
|
|
188
188
|
# -->
|
|
189
|
-
# Returns the product of `self` and `
|
|
189
|
+
# Returns the numeric product of `self` and `other`:
|
|
190
190
|
#
|
|
191
|
+
# Complex.rect(9, 8) * 4 # => (36+32i)
|
|
192
|
+
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
|
|
191
193
|
# Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
|
|
192
194
|
# Complex.rect(900) * Complex.rect(1) # => (900+0i)
|
|
193
195
|
# Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
|
|
194
|
-
# Complex.rect(9, 8) *
|
|
195
|
-
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
|
|
196
|
+
# Complex.rect(9, 8) * Rational(2, 3) # => ((6/1)+(16/3)*i)
|
|
196
197
|
#
|
|
197
198
|
def *: (Numeric) -> Complex
|
|
198
199
|
|
|
199
200
|
# <!--
|
|
200
201
|
# rdoc-file=complex.c
|
|
201
|
-
# -
|
|
202
|
+
# - self ** exponent -> complex
|
|
202
203
|
# -->
|
|
203
|
-
# Returns `self` raised to power `
|
|
204
|
+
# Returns `self` raised to the power `exponent`:
|
|
204
205
|
#
|
|
205
206
|
# Complex.rect(0, 1) ** 2 # => (-1+0i)
|
|
206
207
|
# Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
|
|
@@ -209,15 +210,25 @@ class Complex < Numeric
|
|
|
209
210
|
|
|
210
211
|
# <!--
|
|
211
212
|
# rdoc-file=complex.c
|
|
212
|
-
# -
|
|
213
|
+
# - self + other -> numeric
|
|
213
214
|
# -->
|
|
214
|
-
# Returns the sum of `self` and `
|
|
215
|
+
# Returns the sum of `self` and `other`:
|
|
216
|
+
#
|
|
217
|
+
# Complex(1, 2) + 0 # => (1+2i)
|
|
218
|
+
# Complex(1, 2) + 1 # => (2+2i)
|
|
219
|
+
# Complex(1, 2) + -1 # => (0+2i)
|
|
220
|
+
#
|
|
221
|
+
# Complex(1, 2) + 1.0 # => (2.0+2i)
|
|
215
222
|
#
|
|
216
|
-
# Complex
|
|
217
|
-
# Complex
|
|
218
|
-
#
|
|
219
|
-
# Complex
|
|
220
|
-
# Complex
|
|
223
|
+
# Complex(1, 2) + Complex(2, 1) # => (3+3i)
|
|
224
|
+
# Complex(1, 2) + Complex(2.0, 1.0) # => (3.0+3.0i)
|
|
225
|
+
#
|
|
226
|
+
# Complex(1, 2) + Rational(1, 1) # => ((2/1)+2i)
|
|
227
|
+
# Complex(1, 2) + Rational(1, 2) # => ((3/2)+2i)
|
|
228
|
+
#
|
|
229
|
+
# For a computation involving Floats, the result may be inexact (see Float#+):
|
|
230
|
+
#
|
|
231
|
+
# Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
|
|
221
232
|
#
|
|
222
233
|
def +: (Numeric) -> Complex
|
|
223
234
|
|
|
@@ -225,9 +236,9 @@ class Complex < Numeric
|
|
|
225
236
|
|
|
226
237
|
# <!--
|
|
227
238
|
# rdoc-file=complex.c
|
|
228
|
-
# -
|
|
239
|
+
# - self - other -> complex
|
|
229
240
|
# -->
|
|
230
|
-
# Returns the difference of `self` and `
|
|
241
|
+
# Returns the difference of `self` and `other`:
|
|
231
242
|
#
|
|
232
243
|
# Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
|
|
233
244
|
# Complex.rect(900) - Complex.rect(1) # => (899+0i)
|
|
@@ -239,9 +250,9 @@ class Complex < Numeric
|
|
|
239
250
|
|
|
240
251
|
# <!--
|
|
241
252
|
# rdoc-file=complex.c
|
|
242
|
-
# - -
|
|
253
|
+
# - -self -> complex
|
|
243
254
|
# -->
|
|
244
|
-
# Returns
|
|
255
|
+
# Returns `self`, negated, which is the negation of each of its parts:
|
|
245
256
|
#
|
|
246
257
|
# -Complex.rect(1, 2) # => (-1-2i)
|
|
247
258
|
# -Complex.rect(-1, -2) # => (1+2i)
|
|
@@ -250,9 +261,9 @@ class Complex < Numeric
|
|
|
250
261
|
|
|
251
262
|
# <!--
|
|
252
263
|
# rdoc-file=complex.c
|
|
253
|
-
# -
|
|
264
|
+
# - self / other -> complex
|
|
254
265
|
# -->
|
|
255
|
-
# Returns the quotient of `self` and `
|
|
266
|
+
# Returns the quotient of `self` and `other`:
|
|
256
267
|
#
|
|
257
268
|
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
|
|
258
269
|
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
|
|
@@ -268,15 +279,16 @@ class Complex < Numeric
|
|
|
268
279
|
|
|
269
280
|
# <!--
|
|
270
281
|
# rdoc-file=complex.c
|
|
271
|
-
# -
|
|
282
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
272
283
|
# -->
|
|
284
|
+
# Compares `self` and `other`.
|
|
285
|
+
#
|
|
273
286
|
# Returns:
|
|
274
287
|
#
|
|
275
|
-
# * `self.real <=>
|
|
288
|
+
# * `self.real <=> other.real` if both of the following are true:
|
|
276
289
|
#
|
|
277
290
|
# * `self.imag == 0`.
|
|
278
|
-
# * `
|
|
279
|
-
# complex.
|
|
291
|
+
# * `other.imag == 0` (always true if `other` is numeric but not complex).
|
|
280
292
|
#
|
|
281
293
|
# * `nil` otherwise.
|
|
282
294
|
#
|
|
@@ -289,6 +301,9 @@ class Complex < Numeric
|
|
|
289
301
|
# Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
|
|
290
302
|
# Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
|
|
291
303
|
#
|
|
304
|
+
# Class Complex includes module Comparable, each of whose methods uses
|
|
305
|
+
# Complex#<=> for comparison.
|
|
306
|
+
#
|
|
292
307
|
def <=>: (untyped) -> Integer?
|
|
293
308
|
|
|
294
309
|
# <!--
|
|
@@ -594,9 +609,9 @@ class Complex < Numeric
|
|
|
594
609
|
|
|
595
610
|
# <!--
|
|
596
611
|
# rdoc-file=complex.c
|
|
597
|
-
# -
|
|
612
|
+
# - self / other -> complex
|
|
598
613
|
# -->
|
|
599
|
-
# Returns the quotient of `self` and `
|
|
614
|
+
# Returns the quotient of `self` and `other`:
|
|
600
615
|
#
|
|
601
616
|
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
|
|
602
617
|
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
|
data/core/dir.rbs
CHANGED
|
@@ -171,7 +171,7 @@ class Dir
|
|
|
171
171
|
# system's encoding is used:
|
|
172
172
|
#
|
|
173
173
|
# Dir.new('.').read.encoding # => #<Encoding:UTF-8>
|
|
174
|
-
# Dir.new('.', encoding:
|
|
174
|
+
# Dir.new('.', encoding: Encoding::US_ASCI).read.encoding # => #<Encoding:US-ASCII>
|
|
175
175
|
#
|
|
176
176
|
def initialize: (path dir, ?encoding: encoding?) -> void
|
|
177
177
|
|
|
@@ -704,7 +704,7 @@ class Dir
|
|
|
704
704
|
# system's encoding is used:
|
|
705
705
|
#
|
|
706
706
|
# Dir.open('.').read.encoding # => #<Encoding:UTF-8>
|
|
707
|
-
# Dir.open('.', encoding:
|
|
707
|
+
# Dir.open('.', encoding: Encoding::US_ASCII).read.encoding # => #<Encoding:US-ASCII>
|
|
708
708
|
#
|
|
709
709
|
def self.open: (path dirname, ?encoding: encoding?) -> instance
|
|
710
710
|
| [U] (path dirname, ?encoding: encoding?) { (instance) -> U } -> U
|
data/core/encoding.rbs
CHANGED
|
@@ -281,7 +281,7 @@ class Encoding
|
|
|
281
281
|
def inspect: () -> String
|
|
282
282
|
|
|
283
283
|
# <!-- rdoc-file=encoding.c -->
|
|
284
|
-
#
|
|
284
|
+
# The name of the encoding.
|
|
285
285
|
#
|
|
286
286
|
# Encoding::UTF_8.name #=> "UTF-8"
|
|
287
287
|
#
|
|
@@ -297,12 +297,8 @@ class Encoding
|
|
|
297
297
|
#
|
|
298
298
|
def names: () -> Array[String]
|
|
299
299
|
|
|
300
|
-
# <!--
|
|
301
|
-
#
|
|
302
|
-
# - enc.name -> string
|
|
303
|
-
# - enc.to_s -> string
|
|
304
|
-
# -->
|
|
305
|
-
# Returns the name of the encoding.
|
|
300
|
+
# <!-- rdoc-file=encoding.c -->
|
|
301
|
+
# The name of the encoding.
|
|
306
302
|
#
|
|
307
303
|
# Encoding::UTF_8.name #=> "UTF-8"
|
|
308
304
|
#
|
data/core/enumerable.rbs
CHANGED
|
@@ -2127,7 +2127,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
|
|
|
2127
2127
|
# ["F", 6860]
|
|
2128
2128
|
#
|
|
2129
2129
|
# You can use the special symbol `:_alone` to force an element into its own
|
|
2130
|
-
# separate
|
|
2130
|
+
# separate chunk:
|
|
2131
2131
|
#
|
|
2132
2132
|
# a = [0, 0, 1, 1]
|
|
2133
2133
|
# 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) { |prev| block } -> enumerator
|
|
140
|
+
# - Enumerator.produce(initial = nil, size: 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,6 +169,29 @@ 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
|
+
#
|
|
172
195
|
def self.produce: [T] () { (T? prev) -> T } -> Enumerator[T, bot]
|
|
173
196
|
| [T] (T initial) { (T prev) -> T } -> Enumerator[T, bot]
|
|
174
197
|
|
|
@@ -446,6 +469,25 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
|
|
|
446
469
|
# loop.size # => Float::INFINITY
|
|
447
470
|
# (1..100).drop_while.size # => nil
|
|
448
471
|
#
|
|
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
|
+
#
|
|
449
491
|
def size: () -> (Integer | Float)?
|
|
450
492
|
|
|
451
493
|
# <!--
|
data/core/fiber.rbs
CHANGED
|
@@ -82,7 +82,8 @@ 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
|
|
85
|
+
# The `key` must be a symbol, and the value is set by Fiber#[]= or
|
|
86
|
+
# Fiber#storage.
|
|
86
87
|
#
|
|
87
88
|
# See also Fiber::[]=.
|
|
88
89
|
#
|
|
@@ -392,27 +393,35 @@ class Fiber < Object
|
|
|
392
393
|
|
|
393
394
|
# <!--
|
|
394
395
|
# rdoc-file=cont.c
|
|
395
|
-
# -
|
|
396
|
-
# -
|
|
397
|
-
# - fiber.raise(exception [, string [, array]]) -> obj
|
|
396
|
+
# - raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
|
|
397
|
+
# - raise(message = nil, cause: $!)
|
|
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
|
-
#
|
|
400
|
+
# was called.
|
|
401
|
+
#
|
|
402
|
+
# f = Fiber.new {
|
|
403
|
+
# puts "Before the yield"
|
|
404
|
+
# Fiber.yield 1 # -- exception will be raised here
|
|
405
|
+
# puts "After the yield"
|
|
406
|
+
# }
|
|
407
|
+
#
|
|
408
|
+
# p f.resume
|
|
409
|
+
# f.raise "Gotcha"
|
|
410
|
+
#
|
|
411
|
+
# Output
|
|
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`.
|
|
412
421
|
#
|
|
413
422
|
# Raises `FiberError` if called on a Fiber belonging to another `Thread`.
|
|
414
423
|
#
|
|
415
|
-
# See Kernel#raise for more information.
|
|
424
|
+
# See Kernel#raise for more information on arguments.
|
|
416
425
|
#
|
|
417
426
|
def raise: (?string msg, ?cause: Exception?) -> untyped
|
|
418
427
|
| (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> untyped
|
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 user id of the
|
|
1418
1418
|
# calling process is the owner of the file.
|
|
1419
1419
|
#
|
|
1420
1420
|
# *file_name* can be an IO object.
|
|
@@ -2455,16 +2455,31 @@ class File::Stat < Object
|
|
|
2455
2455
|
|
|
2456
2456
|
# <!--
|
|
2457
2457
|
# rdoc-file=file.c
|
|
2458
|
-
# -
|
|
2458
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
2459
2459
|
# -->
|
|
2460
|
-
# Compares
|
|
2460
|
+
# Compares `self` and `other`, by comparing their modification times; that is,
|
|
2461
|
+
# by comparing `self.mtime` and `other.mtime`.
|
|
2461
2462
|
#
|
|
2462
|
-
#
|
|
2463
|
+
# Returns:
|
|
2463
2464
|
#
|
|
2464
|
-
#
|
|
2465
|
-
#
|
|
2466
|
-
#
|
|
2467
|
-
#
|
|
2465
|
+
# * `-1`, if `self.mtime` is earlier.
|
|
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:
|
|
2471
|
+
#
|
|
2472
|
+
# stat0 = File.stat('README.md')
|
|
2473
|
+
# stat1 = File.stat('NEWS.md')
|
|
2474
|
+
# stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
|
|
2475
|
+
# stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
|
|
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.
|
|
2468
2483
|
#
|
|
2469
2484
|
def <=>: (File::Stat other) -> Integer
|
|
2470
2485
|
| (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 user id of the
|
|
149
149
|
# calling process is the owner of the file.
|
|
150
150
|
#
|
|
151
151
|
# *file_name* can be an IO object.
|