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-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 0A5731F463 for ; Fri, 13 Dec 2019 02:44:02 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C59B5120A6E; Fri, 13 Dec 2019 11:43:44 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 36383120A48 for ; Fri, 13 Dec 2019 11:43:42 +0900 (JST) Received: by filter0037p3iad2.sendgrid.net with SMTP id filter0037p3iad2-28771-5DF2FADC-15 2019-12-13 02:43:40.403905851 +0000 UTC m=+30123.036350327 Received: from herokuapp.com (unknown [34.227.152.143]) by ismtpd0081p1iad2.sendgrid.net (SG) with ESMTP id vGH0ppk3RYWk4Cwk6fkJhQ for ; Fri, 13 Dec 2019 02:43:40.348 +0000 (UTC) Date: Fri, 13 Dec 2019 02:43:40 +0000 (UTC) From: daniel@dan42.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71868 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16377 X-Redmine-Issue-Author: byroot X-Redmine-Sender: Dan0042 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?8sy4RigFvRTdBfCVJrT9zb2J88PC92TMQwdNgaWYaq6Po98sWA4yHENFgD8+si?= =?us-ascii?Q?uedj+V7RCfvu9mwqH=2FjLhA+aVeH8bThrfXKV+Q5?= =?us-ascii?Q?kVtYYl9zqtKYiJ17EmIHlVxlhpBZOzXbVn5YeMN?= =?us-ascii?Q?T1KB=2FUrKD62=2F7jDNeBnkCsZyhiMt=2FSp=2Fq771ZWd?= =?us-ascii?Q?NkegtrgWZO+s0hJf62UF4cvlxNKQ4ZpeBjw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 96216 Subject: [ruby-core:96216] [Ruby master Feature#16377] Regexp literals should be frozen 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 #16377 has been updated by Dan0042 (Daniel DeLorme). > Please don't put ideological thoughts on me, that's not a good basis for debate. Oh no, I'm not. Sorry for the misunderstanding. I was mostly replying to comments in #8948, but I ended up posting here because this is the ticket that is linked in #16393 DevelopersMeeting20191220Japan. Yes, of course when one way is blocked there's always an alternate way of doing things. But the point is that if someone is *currently* relying on Regexp literals not being frozen, this change will break their code. Given that the benefit is close to zero, I don't think it's responsible to force anyone to bear that cost. I'm very conservative about backward compatibility. ---------------------------------------- Feature #16377: Regexp literals should be frozen https://bugs.ruby-lang.org/issues/16377#change-83108 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- The following script: ```ruby def mutate re = /foo/ state = re.instance_variable_get(:@state) re.instance_variable_set(:@state, state.to_i + 1) state end 3.times do p mutate end ``` Output this: ``` nil 1 2 ``` IMHO, you shouldn't be able to mutate an unduplicated literal. GitHub pull request: https://github.com/ruby/ruby/pull/2705 -- https://bugs.ruby-lang.org/