ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95162] [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 23:13:09 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-81799.20190930231308.34f8e2402f69096e@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16181.20190925180551@ruby-lang.org

Issue #16181 has been updated by jeremyevans0 (Jeremy Evans).


I've added a pull request that makes `return` in `proc` in `class`/`module` a `LocalJumpError`: https://github.com/ruby/ruby/pull/2511

----------------------------------------
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-81799

* 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/

  parent reply	other threads:[~2019-09-30 23:13 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 ` [ruby-core:95156] " merch-redmine
2019-09-30 20:11 ` [ruby-core:95159] " tom.enebo
2019-09-30 23:13 ` merch-redmine [this message]
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-81799.20190930231308.34f8e2402f69096e@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).