Feature #22137
openChange `Symbol#to_s` to return frozen strings
Description
Since Ruby 3.4 ([Feature #20350]) Symbol#to_s returns a chilled string, meaning mutating it emits a deprecation warning.
I believe it's now time to act on this deprecation, I'd like to request that on Ruby 4.1, Symbol#to_s always return a frozen string.
Several very large codebases include Shopify and GitHub have been running with Symbol.alias_method(:to_s, :name) without any compatibility issues whatsoever.
Making this change would allow to progressively get rid of an annoying pattern in performance sensitive code:
Updated by byroot (Jean Boussier) 6 days ago
- Related to Feature #20350: Return chilled string from Symbol#to_s added
Updated by headius (Charles Nutter) 6 days ago
Related discussions in https://bugs.ruby-lang.org/issues/16150 where I proposed a way to request frozen strings from to_s. I've always been +1 for all immediate values that return the same string content every time to return frozen strings.
This has shown up as a problem in performance profiles of JRuby apps for decades.