Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Upgrade Ruby to 2.7.8 #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Upgrade Ruby to 2.7.8 #96

wants to merge 1 commit into from

Conversation

depfu[bot]
Copy link
Contributor

@depfu depfu bot commented Apr 1, 2023

Here is everything you need to know about this upgrade. Please take a good look at what changed and the test results before merging this pull request.

What changed?

Release Notes

2.7.8

2.7.7

Posted by usa on 24 Nov 2022

Ruby 2.7.7 has been released.

This release includes a security fix. Please check the topics below for details.

This release also includes some build problem fixes. They are not considered to affect compatibility with previous versions. See the commit logs for further details.

2.7.6

Posted by usa and mame on 12 Apr 2022

Ruby 2.7.6 has been released.

This release includes a security fix. Please check the topics below for details.

This release also includes some bug fixes. See the commit logs for further details.

After thies release, we end the normal maintenance phase of Ruby 2.7, and Ruby 2.7 enters the security maintenance phase. This means that we will no longer backport any bug fixes to Ruby 2.7 excpet security fixes. Ther term of the security maintenance pahse is scheduled for a year. Ruby 2.7 reaches EOL and its official support ends by the end of the security maintenance phase. Therefore, we recommend that you start to plan upgrade to Ruby 3.0 or 3.1.

2.7.5

Posted by usa on 24 Nov 2021

Ruby 2.7.5 has been released.

This release includes security fixes. Please check the topics below for details.

See the commit logs for details.

2.7.4

Posted by usa on 7 Jul 2021

Ruby 2.7.4 has been released.

This release includes security fixes. Please check the topics below for details.

See the commit logs for details.

2.7.3

Posted by nagachika on 5 Apr 2021

Ruby 2.7.3 has been released.

This release includes security fixes. Please check the topics below for details.

See the commit logs for details.

2.7.2

Posted by nagachika on 2 Oct 2020

Ruby 2.7.2 has been released.

This release contains intentional incompatibility. The deprecated warnings are off by default on 2.7.2 and later. You can turn on the deprecated warnings by specifing command line option -w or -W:deprecated. Please check the topics below for details.

This release contains the new version of webrick with a security fix described in the article.

See the commit logs for other changes.

2.7.1

Posted by naruse on 31 Mar 2020

Ruby 2.7.1 has been released.

This release includes security fixes. Please check the topics below for details.

See the commit logs for details.

2.7.0

Posted by naruse on 25 Dec 2019

We are pleased to announce the release of Ruby 2.7.0.

It introduces a number of new features and performance improvements, most notably:

  • Pattern Matching
  • REPL improvement
  • Compaction GC
  • Separation of positional and keyword arguments

Pattern Matching [Experimental]

Pattern matching, a widely used feature in functional programming languages, is introduced as an experimental feature. [Feature #14912]

It can traverse a given object and assign its value if it matches a pattern.

require "json"

json = <<END
{
"name": "Alice",
"age": 30,
"children": [{ "name": "Bob", "age": 2 }]
}
END

case JSON.parse(json, symbolize_names: true)
in {name: "Alice", children: [{name: "Bob", age: age}]}
p age #=> 2
end

For more details, please see Pattern matching - New feature in Ruby 2.7.

REPL improvement

irb, the bundled interactive environment (REPL; Read-Eval-Print-Loop), now supports multi-line editing. It is powered by reline, a readline-compatible library implemented in pure Ruby. It also provides rdoc integration. In irb you can display the reference for a given class, module, or method. [Feature #14683], [Feature #14787], [Feature #14918]

Besides, source lines shown by Binding#irb and inspect results for core-class objects are now colorized.

Compaction GC

This release introduces Compaction GC which can defragment a fragmented memory space.

Some multi-threaded Ruby programs may cause memory fragmentation, leading to high memory usage and degraded speed.

The GC.compact method is introduced for compacting the heap. This function compacts live objects in the heap so that fewer pages may be used, and the heap may be more CoW (copy-on-write) friendly. [Feature #15626]

Separation of positional and keyword arguments

Automatic conversion of keyword arguments and positional arguments is deprecated, and conversion will be removed in Ruby 3. [Feature #14183]

See the article “Separation of positional and keyword arguments in Ruby 3.0” in detail. Only the changes are as follows.

  • When a method call passes a Hash at the last argument, and when it passes no keywords, and when the called method accepts keywords, a warning is emitted. To continue treating the hash as keywords, add a double splat operator to avoid the warning and ensure correct behavior in Ruby 3.

    <div class="language-ruby highlighter-rouge">
    
    def foo(key: 42); end; foo({key: 42})   # warned
    def foo(**kw);    end; foo({key: 42})   # warned
    def foo(key: 42); end; foo(**{key: 42}) # OK
    def foo(**kw);    end; foo(**{key: 42}) # OK
    
  • When a method call passes keywords to a method that accepts keywords, but it does not pass enough required positional arguments, the keywords are treated as a final required positional argument, and a warning is emitted. Pass the argument as a hash instead of keywords to avoid the warning and ensure correct behavior in Ruby 3.

    <div class="language-ruby highlighter-rouge">
    
    def foo(h, **kw); end; foo(key: 42)      # warned
    def foo(h, key: 42); end; foo(key: 42)   # warned
    def foo(h, **kw); end; foo({key: 42})    # OK
    def foo(h, key: 42); end; foo({key: 42}) # OK
    
  • When a method accepts specific keywords but not a keyword splat, and a hash or keywords splat is passed to the method that includes both Symbol and non-Symbol keys, the hash will continue to be split, and a warning will be emitted. You will need to update the calling code to pass separate hashes to ensure correct behavior in Ruby 3.

    <div class="language-ruby highlighter-rouge">
    
    def foo(h={}, key: 42); end; foo("key" => 43, key: 42)   # warned
    def foo(h={}, key: 42); end; foo({"key" => 43, key: 42}) # warned
    def foo(h={}, key: 42); end; foo({"key" => 43}, key: 42) # OK
    
  • If a method does not accept keywords, and is called with keywords, the keywords are still treated as a positional hash, with no warning. This behavior will continue to work in Ruby 3.

    <div class="language-ruby highlighter-rouge">
    
    def foo(opt={});  end; foo( key: 42 )   # OK
    
  • Non-symbols are allowed as keyword argument keys if the method accepts arbitrary keywords. [Feature #14183]

    <div class="language-ruby highlighter-rouge">
    
    def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1}
    
  • **nil is allowed in method definitions to explicitly mark that the method accepts no keywords. Calling such a method with keywords will result in an ArgumentError. [Feature #14183]

    <div class="language-ruby highlighter-rouge">
    
    def foo(h, **nil); end; foo(key: 1)       # ArgumentError
    def foo(h, **nil); end; foo(**{key: 1})   # ArgumentError
    def foo(h, **nil); end; foo("str" => 1)   # ArgumentError
    def foo(h, **nil); end; foo({key: 1})     # OK
    def foo(h, **nil); end; foo({"str" => 1}) # OK
    
  • Passing an empty keyword splat to a method that does not accept keywords no longer passes an empty hash, unless the empty hash is necessary for a required parameter, in which case a warning will be emitted. Remove the double splat to continue passing a positional hash. [Feature #14183]

    <div class="language-ruby highlighter-rouge">
    
    h = {}; def foo(*a) a end; foo(**h) # []
    h = {}; def foo(a) a end; foo(**h)  # {} and warning
    h = {}; def foo(*a) a end; foo(h)   # [{}]
    h = {}; def foo(a) a end; foo(h)    # {}
    

If you want to disable the deprecation warnings, please use a command-line argument -W:no-deprecated or add Warning[:deprecated] = false to your code.

Other Notable New Features

  • Numbered parameters as default block parameters are introduced. [Feature #4475]

  • A beginless range is experimentally introduced. It might not be as useful as an endless range, but would be good for DSL purposes. [Feature #14799]

    <div class="language-ruby highlighter-rouge">
    
    ary[..3]  # identical to ary[0..3]
    rel.where(sales: ..100)
    
  • Enumerable#tally is added. It counts the occurrence of each element.

    <div class="language-ruby highlighter-rouge">
    
    ["a", "b", "c", "b"].tally
    #=> {"a"=>1, "b"=>2, "c"=>1}
    
  • Calling a private method with a literal self as the receiver is now allowed. [Feature #11297], [Feature #16123]

    <div class="language-ruby highlighter-rouge">
    
    def foo
    end
    private :foo
    self.foo
    
  • Enumerator::Lazy#eager is added. It generates a non-lazy enumerator from a lazy enumerator. [Feature #15901]

    <div class="language-ruby highlighter-rouge">
    
    a = %w(foo bar baz)
    e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
    p e.class               #=> Enumerator
    p e.map {|x| x + "?" }  #=> ["FOO!?", "BAR!?", "BAZ!?"]
    

Performance improvements

  • JIT [Experimental]

    <ul>
      <li>
        <p>JIT-ed code is recompiled to less-optimized code when an
    

    optimization assumption is invalidated.




  • Method inlining is performed when a method is considered as pure.
    This optimization is still experimental and many methods are
    NOT considered as pure yet.




  • The default value of --jit-min-calls is changed from 5 to 10,000.




  • The default value of --jit-max-cache is changed from 1,000 to 100.



  • Fiber’s cache strategy is changed and fiber creation is speeded up. GH-2224

  • Module#name, true.to_s, false.to_s, and nil.to_s now always return a frozen String. The returned String is always the same for a given object. [Experimental] [Feature #16150]

  • The performance of CGI.escapeHTML is improved. GH-2226

  • The performance of Monitor and MonitorMixin is improved. [Feature #16255]

  • Per-call-site method cache, which has been there since around 1.9, was improved: cache hit rate raised from 89% to 94%. See GH-2583

  • RubyVM::InstructionSequence#to_binary method generates compiled binary. The binary size is reduced. [Feature #16163]

  • Other notable changes since 2.6

    • Some standard libraries are updated.
    • The following libraries are no longer bundled gems. Install corresponding gems to use these features.
      • CMath (cmath gem)
      • Scanf (scanf gem)
      • Shell (shell gem)
      • Synchronizer (sync gem)
      • ThreadsWait (thwait gem)
      • E2MM (e2mmap gem)
    • profile.rb was removed from standard library.

    • Promote stdlib to default gems
      • The following default gems were published on rubygems.org
        • benchmark
        • cgi
        • delegate
        • getoptlong
        • net-pop
        • net-smtp
        • open3
        • pstore
        • singleton
      • The following default gems were only promoted at ruby-core, but not yet published on rubygems.org.
        • monitor
        • observer
        • timeout
        • tracer
        • uri
        • yaml
    • Proc.new and proc with no block in a method called with a block is warned now.

    • lambda with no block in a method called with a block raises an exception.

    • Update Unicode version and Emoji version from 11.0.0 to 12.0.0. [Feature #15321]

    • Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA. [Feature #15195]

    • Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese era. [Feature #15742]

    • Require compilers to support C99. [Misc #15347]

    See NEWS or commit logs for more details.

    With those changes, 4190 files changed, 227498 insertions(+), 99979 deletions(-) since Ruby 2.6.0!

    Merry Christmas, Happy Holidays, and enjoy programming with Ruby 2.7!


    All Depfu comment commands
    @​depfu refresh
    Rebases against your default branch and redoes this update
    @​depfu recreate
    Recreates this PR, overwriting any edits that you've made to it
    @​depfu merge
    Merges this PR once your tests are passing and conflicts are resolved
    @​depfu close
    Closes this PR and deletes the branch
    @​depfu reopen
    Restores the branch and reopens this PR (if it's closed)
    @​depfu pause
    Pauses all engine updates and closes this PR

    @depfu depfu bot added the depfu label Apr 1, 2023
    @depfu depfu bot mentioned this pull request Apr 1, 2023
    Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    0 participants