123456789_123456789_123456789_123456789_123456789_

NEWS for Ruby 3.1.0

This document is a list of user-visible feature changes since the 3.0.0 release, except for bug fixes.

Note that each entry is kept to a minimum, see links for details.

Language changes

1. `foo`
2. `bar`
3. `[]=` called on the result of `foo`

In Ruby before 3.1.0, multiple assignment did not follow this
evaluation order.  With this code:

```ruby
foo[0], bar.baz = a, b
```

Versions of Ruby before 3.1.0 would evaluate in the following
order

1. `a`
2. `b`
3. `foo`
4. `[]=` called on the result of `foo`
5. `bar`
6. `baz=` called on the result of `bar`

Starting in Ruby 3.1.0, the evaluation order is now consistent with
single assignment, with the left-hand side being evaluated before
the right-hand side:

1. `foo`
2. `bar`
3. `a`
4. `b`
5. `[]=` called on the result of `foo`
6. `baz=` called on the result of `bar`

[[Bug #4443]]

Command line options

Core classes updates

Note: We're only listing outstanding class updates.

Stdlib updates

Compatibility issues

Note: Excluding feature bug fixes.

Stdlib compatibility issues

C API updates

Implementation improvements

JIT

MJIT

YJIT: New experimental in-process JIT compiler

New JIT compiler available as an experimental feature. [Feature #18229]

See this blog post introducing the project.

Static analysis

RBS

See the [CHANGELOG.md]) for more information.

TypeProf

Debugger

error_highlight

A built-in gem called error_highlight has been introduced. It shows fine-grained error locations in the backtrace.

Example: title = json[:article][:title]

If json is nil, it shows:

$ ruby test.rb
test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)

title = json[:article][:title]
            ^^^^^^^^^^

If json[:article] returns nil, it shows:

$ ruby test.rb
test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)

title = json[:article][:title]
                      ^^^^^^^^

This feature is enabled by default. You can disable it by using a command-line option --disable-error_highlight. See the repository in detail.

IRB Autocomplete and Document Display

The IRB now has an autocomplete feature, where you can just type in the code, and the completion candidates dialog will appear. You can use Tab and Shift+Tab to move up and down.

If documents are installed when you select a completion candidate, the documentation dialog will appear next to the completion candidates dialog, showing part of the content. You can read the full document by pressing Alt+d.

Miscellaneous changes