From: marcandre-ruby-core@... Date: 2021-03-20T20:04:57+00:00 Subject: [ruby-core:102965] [Ruby master Bug#17739] Array#sort! changes the order even if the receiver raises FrozenError in given block Issue #17739 has been updated by marcandre (Marc-Andre Lafortune). Is there a usecase for this? ---------------------------------------- Bug #17739: Array#sort! changes the order even if the receiver raises FrozenError in given block https://bugs.ruby-lang.org/issues/17739#change-91028 * Author: kachick (Kenichi Kamiya) * Status: Open * Priority: Normal * ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- I think this is a similar issue of https://bugs.ruby-lang.org/issues/17736 ```ruby array = [1, 2, 3, 4, 5] begin array.sort! do |a, b| array.freeze if a == 3 1 end rescue => err p err #=> # end p array #=> [5, 4, 3, 2, 1] array = [1, 2, 3, 4, 5] array.sort! do |a, b| break if a == 3 1 end p array #=> [3, 4, 2, 1, 5] ``` Array#sort! raises a FrozenError as expected, but the order is changed. I would expect the order is kept after frozen. -- https://bugs.ruby-lang.org/ Unsubscribe: