Bug #1551

String#slice! Raises RuntimeError on Frozen String Despite Making No Changes

Added by Run Paint Run Run almost 6 years ago. Updated almost 4 years ago.

[ruby-core:23658]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 1.9.2dev (2009-05-28 trunk 23601) [i686-linux] Backport:

Description

=begin
On 1.9.2 and 1.9.1 calling String#slice! on a frozen string causes a RuntimeError to be raised even if the method wouldn't have changed the string. This behavior is inconsistent with other operations on frozen strings, and a regression from 1.8.7, on which no exception is raised in this scenario.

The following examples all raise RuntimeErrors on ruby 1.9.2dev (2009-05-28 trunk 23601) [i686-linux]:

"ruby".freeze.slice!(10)
"ruby".freeze.slice!(10,3)
"ruby".freeze.slice!(4,-3)
"ruby".freeze.slice!(10..20)
"ruby".freeze.slice!(/x/)
=end

History

#1 Updated by Yukihiro Matsumoto almost 6 years ago

  • Status changed from Open to Closed

=begin
changed to the opposite way for consistency.

=end

Also available in: Atom PDF