From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95156] [Ruby master Bug#16181] return from a proc in a module/class body returns out of script. Should be LJE.
Date: Mon, 30 Sep 2019 18:32:59 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-81796.20190930183258.f14d8a75e4521f92@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16181.20190925180551@ruby-lang.org
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/
next prev parent reply other threads:[~2019-09-30 18:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-16181.20190925180551@ruby-lang.org>
2019-09-25 18:05 ` [ruby-core:95090] [Ruby master Bug#16181] return from a proc in a module/class body returns out of script. Should be LJE tom.enebo
2019-09-27 23:00 ` [ruby-core:95138] " merch-redmine
2019-09-30 18:21 ` [ruby-core:95155] " tom.enebo
2019-09-30 18:32 ` merch-redmine [this message]
2019-09-30 20:11 ` [ruby-core:95159] " tom.enebo
2019-09-30 23:13 ` [ruby-core:95162] " merch-redmine
2019-10-01 15:03 ` [ruby-core:95174] " tom.enebo
2019-10-02 15:14 ` [ruby-core:95190] " merch-redmine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-81796.20190930183258.f14d8a75e4521f92@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).