Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bundle-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0.0-preview3'
ruby-version: '4.0'

- name: Set up git
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/c-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0.0-preview3"
ruby-version: "4.0"
bundler-cache: none
- name: Set working directory as safe
run: git config --global --add safe.directory $(pwd)
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ on:
jobs:
comments:
runs-on: "ubuntu-latest"
env:
RUBY_COMMIT: v4.0.0-preview3
# env:
# RUBY_COMMIT: v4.0.0-preview2
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: "4.0.0-preview3"
ruby-version: "4.0.0"
bundler: none
- name: Install dependencies
run: |
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['3.2', '3.3', '3.4', '4.0.0-preview3', head]
ruby: ['3.2', '3.3', '3.4', '4.0', head]
rubyopt: [""]
job:
- test
include:
- ruby: head
job: stdlib_test rubocop
- ruby: "4.0.0-preview3"
- ruby: "4.0"
job: stdlib_test
- ruby: "4.0.0-preview3"
- ruby: "4.0"
job: test
rubyopt: "--enable-frozen-string-literal"
- ruby: "4.0.0-preview3"
- ruby: "4.0"
job: stdlib_test
rubyopt: "--enable-frozen-string-literal"
- ruby: "4.0.0-preview3"
- ruby: "4.0"
job: rubocop validate test_doc build test_generate_stdlib raap
- ruby: "4.0.0-preview3"
- ruby: "4.0"
job: typecheck_test
env:
RANDOMIZE_STDLIB_TEST_ORDER: "true"
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['4.0.0-preview3', head]
ruby: ['4.0', head]
steps:
- uses: actions/checkout@v6
- name: Install dependencies
Expand All @@ -100,4 +100,3 @@ jobs:
run: |
bin/setup
- run: bundle exec rake clean compile_c99

9 changes: 8 additions & 1 deletion bin/generate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
set -ex

if [ -z ${RUBY_COMMIT} ]; then
RUBY_COMMIT=v`ruby -e 'puts RUBY_VERSION.gsub(".", "_")'`
RUBY_COMMIT=v`ruby -e '
case
when RUBY_VERSION >= "4.0.0"
puts RUBY_VERSION
else
puts RUBY_VERSION.gsub(".", "_")
end
'`
fi

if [ -z ${RBS_RDOC_BASE_DIR} ]; then
Expand Down
14 changes: 5 additions & 9 deletions core/array.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2029,14 +2029,12 @@ class Array[unchecked out Elem] < Object
# With a block given, calls the block with successive elements of the array;
# returns the first element for which the block returns a truthy value:
#
# (0..9).find {|element| element > 2} # => 3
# [1, 3, 5].find {|element| element > 2} # => 3
#
# If no such element is found, calls `if_none_proc` and returns its return
# value.
#
# (0..9).find(proc {false}) {|element| element > 12} # => false
# {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1]
# {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => []
# [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
#
# With no block given, returns an Enumerator.
#
Expand Down Expand Up @@ -3022,17 +3020,15 @@ class Array[unchecked out Elem] < Object
# Returns the last element for which the block returns a truthy value.
#
# With a block given, calls the block with successive elements of the array in
# reverse order; returns the last element for which the block returns a truthy
# reverse order; returns the first element for which the block returns a truthy
# value:
#
# (0..9).rfind {|element| element < 5} # => 4
# [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4
#
# If no such element is found, calls `if_none_proc` and returns its return
# value.
#
# (0..9).rfind(proc {false}) {|element| element < -2} # => false
# {foo: 0, bar: 1, baz: 2}.rfind {|key, value| key.start_with?('b') } # => [:baz, 2]
# {foo: 0, bar: 1, baz: 2}.rfind(proc {[]}) {|key, value| key.start_with?('c') } # => []
# [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0
#
# With no block given, returns an Enumerator.
#
Expand Down
19 changes: 13 additions & 6 deletions core/comparable.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,26 @@
module Comparable : _WithSpaceshipOperator
# <!--
# rdoc-file=compar.c
# - obj < other -> true or false
# - self < other -> true or false
# -->
# Compares two objects based on the receiver's `<=>` method, returning true if
# it returns a value less than 0.
# Returns whether `self` is "less than" `other`; equivalent to `(self <=> other)
# < 0`:
#
# 'foo' < 'foo' # => false
# 'foo' < 'food' # => true
#
def <: (untyped other) -> bool

# <!--
# rdoc-file=compar.c
# - obj <= other -> true or false
# - self <= other -> true or false
# -->
# Compares two objects based on the receiver's `<=>` method, returning true if
# it returns a value less than or equal to 0.
# Returns whether `self` is "less than or equal to" `other`; equivalent to
# `(self <=> other) <= 0`:
#
# 'foo' <= 'foo' # => true
# 'foo' <= 'food' # => true
# 'food' <= 'foo' # => false
#
def <=: (untyped other) -> bool

Expand Down
12 changes: 8 additions & 4 deletions core/complex.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,16 @@ class Complex < Numeric

# <!--
# rdoc-file=complex.c
# - complex <=> object -> -1, 0, 1, or nil
# - self <=> other -> -1, 0, 1, or nil
# -->
# Compares `self` and `other`.
#
# Returns:
#
# * `self.real <=> object.real` if both of the following are true:
# * `self.real <=> other.real` if both of the following are true:
#
# * `self.imag == 0`.
# * `object.imag == 0`. # Always true if object is numeric but not
# complex.
# * `other.imag == 0` (always true if `other` is numeric but not complex).
#
# * `nil` otherwise.
#
Expand All @@ -298,6 +299,9 @@ class Complex < Numeric
# Complex.rect(1) <=> Complex.rect(1, 1) # => nil # object.imag not zero.
# Complex.rect(1) <=> 'Foo' # => nil # object.imag not defined.
#
# Class Complex includes module Comparable, each of whose methods uses
# Complex#<=> for comparison.
#
def <=>: (untyped) -> Integer?

# <!--
Expand Down
4 changes: 2 additions & 2 deletions core/dir.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Dir
# system's encoding is used:
#
# Dir.new('.').read.encoding # => #<Encoding:UTF-8>
# Dir.new('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
# Dir.new('.', encoding: Encoding::US_ASCI).read.encoding # => #<Encoding:US-ASCII>
#
def initialize: (path dir, ?encoding: encoding?) -> void

Expand Down Expand Up @@ -704,7 +704,7 @@ class Dir
# system's encoding is used:
#
# Dir.open('.').read.encoding # => #<Encoding:UTF-8>
# Dir.open('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
# Dir.open('.', encoding: Encoding::US_ASCII).read.encoding # => #<Encoding:US-ASCII>
#
def self.open: (path dirname, ?encoding: encoding?) -> instance
| [U] (path dirname, ?encoding: encoding?) { (instance) -> U } -> U
Expand Down
25 changes: 25 additions & 0 deletions core/enumerator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# }
# traverser.size # => 4
#
# # Finite enumerator with unknown size
# calendar = Enumerator.produce(Date.today, size: nil) {
# it.monday? ? raise(StopIteration) : it + 1
# }
# calendar.size # => nil
#
def self.produce: [T] () { (T? prev) -> T } -> Enumerator[T, bot]
| [T] (T initial) { (T prev) -> T } -> Enumerator[T, bot]

Expand Down Expand Up @@ -463,6 +469,25 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# loop.size # => Float::INFINITY
# (1..100).drop_while.size # => nil
#
# Note that enumerator size might be inaccurate, and should be rather treated as
# a hint. For example, there is no check that the size provided to ::new is
# accurate:
#
# e = Enumerator.new(5) { |y| 2.times { y << it} }
# e.size # => 5
# e.to_a.size # => 2
#
# Another example is an enumerator created by ::produce without a `size`
# argument. Such enumerators return `Infinity` for size, but this is inaccurate
# if the passed block raises StopIteration:
#
# e = Enumerator.produce(1) { it + 1 }
# e.size # => Infinity
#
# e = Enumerator.produce(1) { it > 3 ? raise(StopIteration) : it + 1 }
# e.size # => Infinity
# e.to_a.size # => 4
#
def size: () -> (Integer | Float)?

# <!--
Expand Down
40 changes: 24 additions & 16 deletions core/fiber.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -404,27 +404,35 @@ class Fiber < Object

# <!--
# rdoc-file=cont.c
# - fiber.raise -> obj
# - fiber.raise(string) -> obj
# - fiber.raise(exception [, string [, array]]) -> obj
# - raise(exception, message = exception.to_s, backtrace = nil, cause: $!)
# - raise(message = nil, cause: $!)
# -->
# Raises an exception in the fiber at the point at which the last `Fiber.yield`
# was called. If the fiber has not been started or has already run to
# completion, raises `FiberError`. If the fiber is yielding, it is resumed. If
# it is transferring, it is transferred into. But if it is resuming, raises
# `FiberError`.
#
# With no arguments, raises a `RuntimeError`. With a single `String` argument,
# raises a `RuntimeError` with the string as a message. Otherwise, the first
# parameter should be the name of an `Exception` class (or an object that
# returns an `Exception` object when sent an `exception` message). The optional
# second parameter sets the message associated with the exception, and the third
# parameter is an array of callback information. Exceptions are caught by the
# `rescue` clause of `begin...end` blocks.
# was called.
#
# f = Fiber.new {
# puts "Before the yield"
# Fiber.yield 1 # -- exception will be raised here
# puts "After the yield"
# }
#
# p f.resume
# f.raise "Gotcha"
#
# Output
#
# Before the first yield
# 1
# t.rb:8:in 'Fiber.yield': Gotcha (RuntimeError)
# from t.rb:8:in 'block in <main>'
#
# If the fiber has not been started or has already run to completion, raises
# `FiberError`. If the fiber is yielding, it is resumed. If it is transferring,
# it is transferred into. But if it is resuming, raises `FiberError`.
#
# Raises `FiberError` if called on a Fiber belonging to another `Thread`.
#
# See Kernel#raise for more information.
# See Kernel#raise for more information on arguments.
#
def raise: (?string msg, ?cause: Exception?) -> untyped
| (_Exception, ?string msg, ?Array[string] | Array[Thread::Backtrace::Location] | nil backtrace, ?cause: Exception?) -> untyped
Expand Down
29 changes: 22 additions & 7 deletions core/file.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2455,16 +2455,31 @@ class File::Stat < Object

# <!--
# rdoc-file=file.c
# - stat <=> other_stat -> -1, 0, 1, nil
# - self <=> other -> -1, 0, 1, or nil
# -->
# Compares File::Stat objects by comparing their respective modification times.
# Compares `self` and `other`, by comparing their modification times; that is,
# by comparing `self.mtime` and `other.mtime`.
#
# `nil` is returned if `other_stat` is not a File::Stat object
# Returns:
#
# f1 = File.new("f1", "w")
# sleep 1
# f2 = File.new("f2", "w")
# f1.stat <=> f2.stat #=> -1
# * `-1`, if `self.mtime` is earlier.
# * `0`, if the two values are equal.
# * `1`, if `self.mtime` is later.
# * `nil`, if `other` is not a File::Stat object.
#
# Examples:
#
# stat0 = File.stat('README.md')
# stat1 = File.stat('NEWS.md')
# stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
# stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
# stat0 <=> stat1 # => -1
# stat0 <=> stat0.dup # => 0
# stat1 <=> stat0 # => 1
# stat0 <=> :foo # => nil
#
# Class File::Stat includes module Comparable, each of whose methods uses
# File::Stat#<=> for comparison.
#
def <=>: (File::Stat other) -> Integer
| (untyped) -> nil
Expand Down
Loading