From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 17FC51F990 for ; Thu, 6 Aug 2020 10:12:31 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 18FF0120B39; Thu, 6 Aug 2020 19:11:54 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 6E9AA120B36 for ; Thu, 6 Aug 2020 19:11:52 +0900 (JST) Received: by filterdrecv-p3las1-559bd7b968-l9bgl with SMTP id filterdrecv-p3las1-559bd7b968-l9bgl-19-5F2BD783-89 2020-08-06 10:12:20.062115889 +0000 UTC m=+662170.729210072 Received: from herokuapp.com (unknown) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id jzZxJ5QQQZydvS8uC-C_aA for ; Thu, 06 Aug 2020 10:12:19.841 +0000 (UTC) Date: Thu, 06 Aug 2020 10:12:20 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 75323 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 17104 X-Redmine-Issue-Author: bughit X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr1KM180J1KahkGhk3PUSi?= =?us-ascii?Q?qKRYBqu7gO3A8ZFi5oi1PHyjJe1A8CEalWUV6HI?= =?us-ascii?Q?Xa3=2FDNp+bbFtj2pFhsG1c7+zW7rCvHyLaa7Bs9Z?= =?us-ascii?Q?m+Z6CetmX=2FB2Ty5Xm2vdfuLgK=2F3wEi9I5X7IYFN?= =?us-ascii?Q?2CDugatMMI2SKGSgItXgwpv7mnPi83Lor8C=2FN+K?= =?us-ascii?Q?xAfO+HzPYEhz9GHPQ=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 99497 Subject: [ruby-core:99497] [Ruby master Feature#17104] Do not freeze interpolated strings when using frozen-string-literal X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #17104 has been updated by Eregon (Benoit Daloze). byroot (Jean Boussier) wrote in #note-8: > Because I understand the consistency argument. "All string literals are frozen" is much easier to wrap your head around than "All string literals are frozen except the ones that are interpolated". I'd argue `"a#{2}c"` is not a string literal (`"a2c"` is a string literal). It's actually syntactic sugar for `mutableEmptyStringOfSourceEncoding << "a" << 2.to_s << "c"`. (+ `.freeze` everything in current semantics which feels unneeded) Same as `42` is an integer literal, but `41 + 1` is not an integer literal. ---------------------------------------- Feature #17104: Do not freeze interpolated strings when using frozen-string-literal https://bugs.ruby-lang.org/issues/17104#change-86955 * Author: bughit (bug hit) * Status: Open * Priority: Normal ---------------------------------------- ```rb #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' ``` Isn't the point of frozen literals to avoid needless allocations? But interpolated strings are allocated each time, so freezing appears pointless. -- https://bugs.ruby-lang.org/