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 098AA1F463 for ; Mon, 30 Sep 2019 20:11:40 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 1561F120913; Tue, 1 Oct 2019 05:11:23 +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 AA6981208F8 for ; Tue, 1 Oct 2019 05:11:20 +0900 (JST) Received: by filter0104p3las1.sendgrid.net with SMTP id filter0104p3las1-29704-5D926166-5A 2019-09-30 20:11:18.849489479 +0000 UTC m=+607880.323231453 Received: from herokuapp.com (unknown [18.232.111.68]) by ismtpd0058p1mdw1.sendgrid.net (SG) with ESMTP id PaJ7na0ITr2IhaJslcxqpA for ; Mon, 30 Sep 2019 20:11:18.779 +0000 (UTC) Date: Mon, 30 Sep 2019 20:11:18 +0000 (UTC) From: tom.enebo@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70714 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=2F7GsuVdUT8RQZ9PoP2BNsQ6OqTKbiOoI2kZ7J?= =?us-ascii?Q?FVSBJFNQ1qpR92dVNPimPw6PRjfE4ucLfl9nIQK?= =?us-ascii?Q?Psryh0Exoqc6GTqcg9mStM1EQwwp5Lu2zVSOFOl?= =?us-ascii?Q?S9Yjhrs+42Bu4XmzivmY5mOdVMnUXZr8Z1ZGvfQ?= =?us-ascii?Q?glHzOgS4XNss2A5A1npXDvPWvMitp3xobmQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95159 Subject: [ruby-core:95159] [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). Ok cool. Let's hope we get some more consensus on this. I don't like deviating from MRI in behavior so I hope to see more come to the same conclusion. ---------------------------------------- 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-81798 * 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/