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 B04C61F463 for ; Mon, 30 Sep 2019 18:33:08 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id A4B41120933; Tue, 1 Oct 2019 03:32:59 +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 791CF120933 for ; Tue, 1 Oct 2019 03:32:57 +0900 (JST) Received: by filter0061p3iad2.sendgrid.net with SMTP id filter0061p3iad2-3639-5D924A5B-67 2019-09-30 18:32:59.756630747 +0000 UTC m=+596428.600693632 Received: from herokuapp.com (unknown [18.232.111.68]) by ismtpd0082p1iad2.sendgrid.net (SG) with ESMTP id wVAYWVgHSHWnNHxate8cmg for ; Mon, 30 Sep 2019 18:32:59.667 +0000 (UTC) Date: Mon, 30 Sep 2019 18:32:59 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70711 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16181 X-Redmine-Issue-Author: enebo X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIkxo+0UAHk+gHukLiIDhwIFxAVLp0vfeNcUCBi?= =?us-ascii?Q?fFMHKTUQJo0I0F4wOYg2I6OCKDHBNQyaTnk=2FG1q?= =?us-ascii?Q?sYEa9C2spMDApMPnPLi4Gr7sAf94cCbzzWWYBFM?= =?us-ascii?Q?QbBmQAbNOQv0jUFtTRPwaxzEiUmMKtUc2Og=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95156 Subject: [ruby-core:95156] [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 jeremyevans0 (Jeremy Evans). enebo (Thomas Enebo) wrote: > Jeremy, since you are only person who has looked would you say semantically this should be some error vs silently only executing part of a file? I believe if `return` directly inside `class`/`module` is an error, `return` inside `proc` inside `class`/`module` should also be an error. Since it cannot be a compile time error, it should be a runtime error (`LocalJumpError`). Alternatively, we start to allow `return` inside `class`/`module`, and then the current behavior for `return` inside `proc` inside `class`/`module` makes sense. ---------------------------------------- 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-81796 * 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/