Project

General

Profile

Actions

Bug #11841

closed

StringIO with read and `nil, ''` arguments broken with enabled frozen string literal

Added by deepj (deepj #) over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-12-19 trunk 53195) [x86_64-darwin15]
[ruby-core:72367]

Description

I'm not sure what behavior is expected here. But the following use case is used in rack (https://github.com/rack/rack/blob/master/test/spec_lint.rb#L496). If frozen string literal is enabled it throws `read': can't modify frozen String (RuntimeError), otherwise nothing.

# frozen_string_literal: true

io = StringIO.new('')

io.read(*[nil, ''])

Updated by deepj (deepj #) over 8 years ago

  • ruby -v set to ruby 2.3.0dev (2015-12-19 trunk 53195) [x86_64-darwin15]

Updated by shugo (Shugo Maeda) over 8 years ago

  • Status changed from Open to Rejected

deepj # wrote:

# frozen_string_literal: true

io = StringIO.new('')

io.read(*[nil, ''])

The second argument of StringIO#read is a buffer to read, so it shouldn't be frozen.

io.read(*[nil, String.new])

Updated by deepj (deepj #) over 8 years ago

Thanks. In fact, I didn't realized the second argument is actually a buffer. My mistake

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0