Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do modifyCheck for each pair in Array#sort! #5021

Merged
merged 1 commit into from Feb 1, 2018

Conversation

Projects
None yet
4 participants
@ChrisBr
Copy link
Contributor

ChrisBr commented Jan 29, 2018

as calling comparison could freeze the Array and should trigger a RuntimeError.

Do modifyCheck for each pair in Array#sort!
as calling comparison could freeze the Array and should trigger a RuntimeError.
@olleolleolle

This comment has been minimized.

Copy link
Contributor

olleolleolle commented Jan 30, 2018

Cross-referencing links: only informative and additive, to describe this change.

The test was:

  def test_sort_bang_with_freeze
    ary = []
    o1 = Object.new
    o1.singleton_class.class_eval {
      define_method(:<=>) {|v|
        ary.freeze
        1
      }
    }
    o2 = o1.clone
    ary << o1 << o2
    orig = ary.dup
    assert_raise(FrozenError, "frozen during comparison") {ary.sort!}
    assert_equal(orig, ary, "must not be modified once frozen")
  end

https://github.com/ruby/ruby/blob/978be08b9db29cf190ef483320ed8c6d3df00091/test/ruby/test_array.rb#L1521-L1535

This Git blame view shows that 2 months ago, there was a change so that the FrozenError now had become a RuntimeError subclass.
https://github.com/ruby/ruby/blame/978be08b9db29cf190ef483320ed8c6d3df00091/test/ruby/test_array.rb#L1521-L1535

@ChrisBr

This comment has been minimized.

Copy link
Contributor Author

ChrisBr commented Feb 1, 2018

@olleolleolle @kares should I change it in this PR? Because this one is targeting master but I guess the change is for 2.5, right?

@olleolleolle

This comment has been minimized.

Copy link
Contributor

olleolleolle commented Feb 1, 2018

@ChrisBr My additional comment about the evolution of Ruby was only informative.

My take: Keep them separate, take no further action for this PR.

@kares

This comment has been minimized.

Copy link
Member

kares commented Feb 1, 2018

fixed an existing spec, seems no new ones broke. so all should be good as is - @enebo okay to merge?

@enebo enebo added this to the JRuby 9.2.0.0 milestone Feb 1, 2018

@enebo enebo merged commit 68c886e into jruby:master Feb 1, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.