Project

General

Profile

Actions

Bug #1551

closed

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

Added by runpaint (Run Paint Run Run) almost 15 years ago. Updated almost 13 years ago.

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

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

Actions

Also available in: Atom PDF

Like0
Like0