Issue #14475 has been updated by sam.saffron (Sam Saffron).


I created a new topic for this at: https://bugs.ruby-lang.org/issues/14478 

> At this point, it may break existing code :<

I think it is worth the risk cause adding #fstring here seem overkill and almost nobody would be using uminus now anyway cause they do not know about it. 

----------------------------------------
Bug #14475: String de-duplication is broken in files with frozen_string_literal: true
https://bugs.ruby-lang.org/issues/14475#change-70359

* Author: sam.saffron (Sam Saffron)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.5.0, 2.6.0
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
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. 




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>