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.0 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_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 9A64E1F804 for ; Fri, 28 Dec 2018 23:30:36 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BC067121142; Sat, 29 Dec 2018 08:30:33 +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 F2A8E12103E for ; Sat, 29 Dec 2018 08:30:30 +0900 (JST) Received: by filter0058p3mdw1.sendgrid.net with SMTP id filter0058p3mdw1-19124-5C26B213-5D 2018-12-28 23:30:27.734529214 +0000 UTC m=+696330.289063980 Received: from herokuapp.com (ec2-54-80-146-178.compute-1.amazonaws.com [54.80.146.178]) by ismtpd0012p1iad2.sendgrid.net (SG) with ESMTP id E1g3l2g6QHWajDEu2GMQGw Fri, 28 Dec 2018 23:30:27.933 +0000 (UTC) Date: Fri, 28 Dec 2018 23:30:28 +0000 (UTC) From: Greg.mpls@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66202 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15479 X-Redmine-Issue-Author: Eregon X-Redmine-Sender: MSP-Greg 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7ZXzjRv3rhd6xXKIWo/D367A0HQJB2xoge4l e5kS3S9KgVsrIZ6L3l1nLr3EQfo3StC/WBs5+lZRQk/ThcUZB6TzjGYuf1SYiPCI9wrx6nou2MBll+ mw3cEp7msnm2Wo3WxirEaBJ8T/2qYedLrV7ZP9bW5QsuaWwMQ//kcMNWzw== X-ML-Name: ruby-core X-Mail-Count: 90782 Subject: [ruby-core:90782] [Ruby trunk Bug#15479] Array#reject! modifies literal Array 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 #15479 has been updated by MSP-Greg (Greg L). Is the distinction really whether 2.6.0 & trunk only modify the array if `reject!` successfully enumerates all array members? Commenting out `when 3 then raise StandardError, 'Oops'`, all versions act the same... ---------------------------------------- Bug #15479: Array#reject! modifies literal Array https://bugs.ruby-lang.org/issues/15479#change-75955 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux] * Backport: 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED ---------------------------------------- This was found by running ruby/spec with -R2 (such as mspec -R2 -fs core/array/reject_spec.rb). TravisCI log on https://travis-ci.org/ruby/spec/jobs/473175799#L539 Here is a simple reproducer. MRI seems to modify the Array literal permanently: ```ruby 3.times do a = [1, 2, 3, 4] puts "initial: #{a}" begin a.reject! do |x| case x when 2 then true when 3 then raise StandardError, 'Oops' else false end end rescue StandardError end puts "after: #{a}" end ``` prints ``` initial: [1, 2, 3, 4] after: [1, 3, 4] initial: [1, 3, 4, 4] after: [1, 3, 4, 4] initial: [1, 3, 4, 4] after: [1, 3, 4, 4] ``` 2.5.3 behaves fine, but trunk is also affected. -- https://bugs.ruby-lang.org/