Ruby 3.4.0 preview2 Released

We are pleased to announce the release of Ruby 3.4.0-preview2.

Prism

Switch the default parser from parse.y to Prism. [Feature #20564]

Language changes

  • String literals in files without a frozen_string_literal comment now emit a deprecation warning when they are mutated. These warnings can be enabled with -W:deprecated or by setting Warning[:deprecated] = true. To disable this change, you can run Ruby with the --disable-frozen-string-literal command line argument. [Feature #20205]

  • it is added to reference a block parameter. [Feature #18980]

  • Keyword splatting nil when calling methods is now supported. **nil is treated similarly to **{}, passing no keywords, and not calling any conversion methods. [Bug #20064]

  • Block passing is no longer allowed in index. [Bug #19918]

  • Keyword arguments are no longer allowed in index. [Bug #20218]

Core classes updates

Note: We’re only listing outstanding class updates.

  • Exception

    • Exception#set_backtrace now accepts an array of Thread::Backtrace::Location. Kernel#raise, Thread#raise and Fiber#raise also accept this new format. [Feature #13557]
  • Range

    • Range#size now raises TypeError if the range is not iterable. [Misc #18984]

Compatibility issues

Note: Excluding feature bug fixes.

  • Error messages and backtrace displays have been changed.
    • Use a single quote instead of a backtick as a opening quote. [Feature #16495]
    • Display a class name before a method name (only when the class has a permanent name). [Feature #19117]
    • Kernel#caller, Thread::Backtrace::Location’s methods, etc. are also changed accordingly.
    Old:
    test.rb:1:in `foo': undefined method `time' for an instance of Integer
            from test.rb:2:in `<main>'
    
    New:
    test.rb:1:in 'Object#foo': undefined method 'time' for an instance of Integer
            from test.rb:2:in '<main>'
    
  • Hash#inspect rendering has changed. [Bug #20433]
    • Symbol keys are displayed using the modern symbol key syntax: "{user: 1}"
    • Other keys now have spaces around =>: '{"user" => 1}', while previously they didn’t: '{"user"=>1}'

C API updates

  • rb_newobj and rb_newobj_of (and corresponding macros RB_NEWOBJ, RB_NEWOBJ_OF, NEWOBJ, NEWOBJ_OF) have been removed. [Feature #20265]
  • Removed deprecated function rb_gc_force_recycle. [Feature #18290]

Implementation improvements

  • Array#each is rewritten in Ruby for better performance [Feature #20182].

Miscellaneous changes

  • Passing a block to a method which doesn’t use the passed block will show a warning on verbose mode (-w). [Feature #15554]

  • Redefining some core methods that are specially optimized by the interpeter and JIT like String.freeze or Integer#+ now emits a performance class warning (-W:performance or Warning[:performance] = true). [Feature #20429]

See GitHub releases like Logger or changelog for details of the default gems or bundled gems.

See NEWS or commit logs for more details.

With those changes, 4422 files changed, 163889 insertions(+), 243380 deletions(-) since Ruby 3.3.0!

Download

What is Ruby

Ruby was first developed by Matz (Yukihiro Matsumoto) in 1993, and is now developed as Open Source. It runs on multiple platforms and is used all over the world especially for web development.



OSZAR »