Project

General

Profile

Actions

Feature #17104

closed

Do not freeze interpolated strings when using frozen-string-literal

Added by bughit (bug hit) 12 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:99485]

Description

I think the point of frozen string literals is to avoid needless allocations. Interpolated strings are allocated each time, so freezing them appears pointless.

#frozen_string_literal: true

def foo(str)
  "#{str}"
end

fr1 = 'a'
fr2 = 'a'
fr1_1 = foo(fr1)
fr2_1 = foo(fr2)

puts fr1.__id__, fr2.__id__, fr1_1.__id__, fr2_1.__id__

puts fr1_1 << 'b'

Related issues

Is duplicate of Ruby master - Misc #16047: Reconsider impact of frozen_string_literal on dynamic stringsClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF