Issue #15241 has been updated by Eregon (Benoit Daloze).


I think it's very bad style to modify the return value of #inspect, and some objects do already return frozen strings for #inspect.
So I think it would be a fair enough to change as it seems to have very low risk, i.e.,
it would only break code which is questionable in the first place (and should use `+` or interpolation instead).

OTOH, it's likely irrelevant for performance, and could likely be optimized if needed anyway.
So I think there is not much to gain either way, but conceptually it's wrong for user code to assume the result #inspect is always mutable.

----------------------------------------
Bug #15241: net/pop fix to use mutable strings was too eager
https://bugs.ruby-lang.org/issues/15241#change-74673

* Author: eventualbuddha (Brian Donovan)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.5.2
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
See [[https://github.com/ruby/ruby/commit/3993fbb5f6bfdae0bce040988d7e2dd632247cdc#commitcomment-30987842|this thread on Github]]. I believe the changes made in Backport #14416 for 2.5.2 (on both trunk and 2.5.x) over-eagerly applied mutability to literal strings. In particular, the strings returned by `inspect` have no real need to be mutable as far as I can tell.



-- 
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>