Skip to content

Commit fe6df89

Browse files
authored
Merge pull request #2764 from ruby/ruby-4.0.0-preview3
Ruby 4.0.0 preview3
2 parents 0b146c4 + 036a580 commit fe6df89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2050
-692
lines changed

.github/workflows/bundle-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Ruby
1717
uses: ruby/setup-ruby@v1
1818
with:
19-
ruby-version: '4.0.0-preview2'
19+
ruby-version: '4.0.0-preview3'
2020

2121
- name: Set up git
2222
run: |

.github/workflows/c-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v6
1313
- uses: ruby/setup-ruby@v1
1414
with:
15-
ruby-version: "4.0.0-preview2"
15+
ruby-version: "4.0.0-preview3"
1616
bundler-cache: none
1717
- name: Set working directory as safe
1818
run: git config --global --add safe.directory $(pwd)

.github/workflows/comments.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
comments:
1212
runs-on: "ubuntu-latest"
1313
env:
14-
RUBY_COMMIT: v4.0.0-preview2
14+
RUBY_COMMIT: v4.0.0-preview3
1515
steps:
1616
- uses: actions/checkout@v6
1717
- uses: ruby/setup-ruby@v1
1818
with:
19-
ruby-version: "4.0.0-preview2"
19+
ruby-version: "4.0.0-preview3"
2020
bundler: none
2121
- name: Install dependencies
2222
run: |

.github/workflows/ruby.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
ruby: ['3.2', '3.3', '3.4', '4.0.0-preview2', head]
16+
ruby: ['3.2', '3.3', '3.4', '4.0.0-preview3', head]
1717
rubyopt: [""]
1818
job:
1919
- test
2020
include:
2121
- ruby: head
2222
job: stdlib_test rubocop
23-
- ruby: "4.0.0-preview2"
23+
- ruby: "4.0.0-preview3"
2424
job: stdlib_test
25-
- ruby: "4.0.0-preview2"
25+
- ruby: "4.0.0-preview3"
2626
job: test
2727
rubyopt: "--enable-frozen-string-literal"
28-
- ruby: "4.0.0-preview2"
28+
- ruby: "4.0.0-preview3"
2929
job: stdlib_test
3030
rubyopt: "--enable-frozen-string-literal"
31-
- ruby: "4.0.0-preview2"
31+
- ruby: "4.0.0-preview3"
3232
job: rubocop validate test_doc build test_generate_stdlib raap
33-
- ruby: "4.0.0-preview2"
33+
- ruby: "4.0.0-preview3"
3434
job: typecheck_test
3535
env:
3636
RANDOMIZE_STDLIB_TEST_ORDER: "true"
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
ruby: ['4.0.0-preview2', head]
77+
ruby: ['4.0.0-preview3', head]
7878
steps:
7979
- uses: actions/checkout@v6
8080
- name: Install dependencies

core/array.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ class Array[unchecked out Elem] < Object
12131213
# Returns the element from `self` found by a binary search, or `nil` if the
12141214
# search found no suitable element.
12151215
#
1216-
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
1216+
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
12171217
#
12181218
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
12191219
#
@@ -1229,7 +1229,7 @@ class Array[unchecked out Elem] < Object
12291229
# Returns the integer index of the element from `self` found by a binary search,
12301230
# or `nil` if the search found no suitable element.
12311231
#
1232-
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
1232+
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
12331233
#
12341234
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
12351235
#
@@ -2618,7 +2618,7 @@ class Array[unchecked out Elem] < Object
26182618
# - pack(template, buffer: nil) -> string
26192619
# -->
26202620
# Formats each element in `self` into a binary string; returns that string. See
2621-
# [Packed Data](rdoc-ref:packed_data.rdoc).
2621+
# [Packed Data](rdoc-ref:language/packed_data.rdoc).
26222622
#
26232623
def pack: (string fmt, ?buffer: String?) -> String
26242624

core/complex.rbs

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,23 +184,24 @@ class Complex < Numeric
184184

185185
# <!--
186186
# rdoc-file=complex.c
187-
# - complex * numeric -> new_complex
187+
# - self * other -> numeric
188188
# -->
189-
# Returns the product of `self` and `numeric`:
189+
# Returns the numeric product of `self` and `other`:
190190
#
191+
# Complex.rect(9, 8) * 4 # => (36+32i)
192+
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
191193
# Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
192194
# Complex.rect(900) * Complex.rect(1) # => (900+0i)
193195
# Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
194-
# Complex.rect(9, 8) * 4 # => (36+32i)
195-
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
196+
# Complex.rect(9, 8) * Rational(2, 3) # => ((6/1)+(16/3)*i)
196197
#
197198
def *: (Numeric) -> Complex
198199

199200
# <!--
200201
# rdoc-file=complex.c
201-
# - complex ** numeric -> new_complex
202+
# - self ** exponent -> complex
202203
# -->
203-
# Returns `self` raised to power `numeric`:
204+
# Returns `self` raised to the power `exponent`:
204205
#
205206
# Complex.rect(0, 1) ** 2 # => (-1+0i)
206207
# Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
@@ -209,23 +210,33 @@ class Complex < Numeric
209210

210211
# <!--
211212
# rdoc-file=complex.c
212-
# - complex + numeric -> new_complex
213+
# - self + other -> numeric
213214
# -->
214-
# Returns the sum of `self` and `numeric`:
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)
222+
#
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#+):
215230
#
216-
# Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
217-
# Complex.rect(900) + Complex.rect(1) # => (901+0i)
218-
# Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
219-
# Complex.rect(9, 8) + 4 # => (13+8i)
220-
# Complex.rect(20, 9) + 9.8 # => (29.8+9i)
231+
# Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
221232
#
222233
def +: (Numeric) -> Complex
223234

224235
# <!--
225236
# rdoc-file=complex.c
226-
# - complex - numeric -> new_complex
237+
# - self - other -> complex
227238
# -->
228-
# Returns the difference of `self` and `numeric`:
239+
# Returns the difference of `self` and `other`:
229240
#
230241
# Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
231242
# Complex.rect(900) - Complex.rect(1) # => (899+0i)
@@ -237,9 +248,9 @@ class Complex < Numeric
237248

238249
# <!--
239250
# rdoc-file=complex.c
240-
# - -complex -> new_complex
251+
# - -self -> complex
241252
# -->
242-
# Returns the negation of `self`, which is the negation of each of its parts:
253+
# Returns `self`, negated, which is the negation of each of its parts:
243254
#
244255
# -Complex.rect(1, 2) # => (-1-2i)
245256
# -Complex.rect(-1, -2) # => (1+2i)
@@ -248,9 +259,9 @@ class Complex < Numeric
248259

249260
# <!--
250261
# rdoc-file=complex.c
251-
# - complex / numeric -> new_complex
262+
# - self / other -> complex
252263
# -->
253-
# Returns the quotient of `self` and `numeric`:
264+
# Returns the quotient of `self` and `other`:
254265
#
255266
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
256267
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
@@ -597,9 +608,9 @@ class Complex < Numeric
597608

598609
# <!--
599610
# rdoc-file=complex.c
600-
# - complex / numeric -> new_complex
611+
# - self / other -> complex
601612
# -->
602-
# Returns the quotient of `self` and `numeric`:
613+
# Returns the quotient of `self` and `other`:
603614
#
604615
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
605616
# Complex.rect(900) / Complex.rect(1) # => (900+0i)

core/encoding.rbs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class Encoding
281281
def inspect: () -> String
282282

283283
# <!-- rdoc-file=encoding.c -->
284-
# Returns the name of the encoding.
284+
# The name of the encoding.
285285
#
286286
# Encoding::UTF_8.name #=> "UTF-8"
287287
#
@@ -297,12 +297,8 @@ class Encoding
297297
#
298298
def names: () -> Array[String]
299299

300-
# <!--
301-
# rdoc-file=encoding.c
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.
306302
#
307303
# Encoding::UTF_8.name #=> "UTF-8"
308304
#

core/enumerable.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
21362136
# ["F", 6860]
21372137
#
21382138
# You can use the special symbol `:_alone` to force an element into its own
2139-
# separate chuck:
2139+
# separate chunk:
21402140
#
21412141
# a = [0, 0, 1, 1]
21422142
# e = a.chunk{|i| i.even? ? :_alone : true }

core/enumerator.rbs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
137137

138138
# <!--
139139
# rdoc-file=enumerator.c
140-
# - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
140+
# - Enumerator.produce(initial = nil, size: nil) { |prev| block } -> enumerator
141141
# -->
142142
# Creates an infinite enumerator from any block, just called over and over. The
143143
# result of the previous iteration is passed to the next one. If `initial` is
@@ -169,6 +169,23 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
169169
# Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
170170
# # => ["7", "+", "38", "/", "6"]
171171
#
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+
#
172189
def self.produce: [T] () { (T? prev) -> T } -> Enumerator[T, bot]
173190
| [T] (T initial) { (T prev) -> T } -> Enumerator[T, bot]
174191

core/fiber.rbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class Fiber < Object
8282
# -->
8383
# Returns the value of the fiber storage variable identified by `key`.
8484
#
85-
# The `key` must be a symbol, and the value is set by Fiber#[]= or Fiber#store.
85+
# The `key` must be a symbol, and the value is set by Fiber#[]= or
86+
# Fiber#storage.
8687
#
8788
# See also Fiber::[]=.
8889
#

0 commit comments

Comments
 (0)