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

ChrisBr
Copy link
Contributor

@ChrisBr ChrisBr commented Jan 29, 2018

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

as calling comparison could freeze the Array and should trigger a RuntimeError.
@olleolleolle
Copy link
Member

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
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
Copy link
Member

@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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants