Project

General

Profile

Actions

Bug #14475

closed

String de-duplication is broken in files with frozen_string_literal: true

Added by sam.saffron (Sam Saffron) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.5.0, 2.6.0
[ruby-core:85542]

Description

Create 2 files:

test.rb

$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'frozen'

puts frozen.object_id
puts frozen.object_id

frozen.rb

# frozen_string_literal: true

A = "a"
def frozen
  -"#{A}"
end

Run test.rb

% ruby test.rb
70189973179400
70189973179260

Change to # frozen_string_literal: false

And you get

70189973181360
70189973181360

So something is over-optimising here, fix should be backported to 2.5.0 imo.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14478: String #uminus should de-dupe unconditionallyClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0