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=-2.8 required=3.0 tests=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 shortcircuit=no autolearn=no 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 AC39F1F4BD for ; Tue, 1 Oct 2019 15:03:36 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 52C03120A2C; Wed, 2 Oct 2019 00:03:28 +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 C923B1209A5 for ; Wed, 2 Oct 2019 00:03:25 +0900 (JST) Received: by filter0055p3iad2.sendgrid.net with SMTP id filter0055p3iad2-6450-5D936ABD-6C 2019-10-01 15:03:25.61840047 +0000 UTC m=+670734.676715063 Received: from herokuapp.com (unknown [54.173.8.255]) by ismtpd0050p1mdw1.sendgrid.net (SG) with ESMTP id I3yx9kNISvu9WUveIUhsTg for ; Tue, 01 Oct 2019 15:03:25.521 +0000 (UTC) Date: Tue, 01 Oct 2019 15:03:25 +0000 (UTC) From: tom.enebo@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70729 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16181 X-Redmine-Issue-Author: enebo X-Redmine-Sender: enebo 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?CEgjm=2FKgaDwZgtms5cDYrJb3X=2F7GsuVdUT8RQZ9PoP25KGwz+aR3G6IbQro8Z3?= =?us-ascii?Q?kXghGO2gr6iYuDwxMSngT4YjbVhF=2FYbUgR+sJeH?= =?us-ascii?Q?30ERpvt8b3FBF41wMXTRI5AdxennlzROUTsXeTp?= =?us-ascii?Q?kysfJHllAzmFJWDBWWOrY46WSVTEwT8xKdJ8mnu?= =?us-ascii?Q?3DNlctacnt7C9e4bh2snl8vw4Gne0XfT=2FIw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95174 Subject: [ruby-core:95174] [Ruby master Bug#16181] return from a proc in a module/class body returns out of script. Should be LJE. 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 #16181 has been updated by enebo (Thomas Enebo). I added a comment about removing the pre 2.7 spec as it is unintended behavior. ---------------------------------------- Bug #16181: return from a proc in a module/class body returns out of script. Should be LJE. https://bugs.ruby-lang.org/issues/16181#change-81809 * Author: enebo (Thomas Enebo) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- return is not allowed from class/module body. But if we insert a return into a block then we can invoke the block then it returns all the way out of the script. This has to be accidental behavior doesn't it? I believe the case below should end up as a LocalJumpError: ``` class Foo proc { return }.call end puts "NEVER SEEN" ``` This behavior started some time in 2.5 (it used to be an LJE). -- https://bugs.ruby-lang.org/