Forum: Ruby-core Calling return within begin still executes else

C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 Mayank Kohaley (Guest)
on 2011-04-06 14:17
(Received via mailing list)
Issue #4473 has been updated by Mayank Kohaley.


I can see the same issue happening on Windows also.
----------------------------------------
Bug #4473: Calling return within begin still executes else
http://redmine.ruby-lang.org/issues/4473

Author: Todd Huss
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.2p136 (2010-12-25 revision 30365)
[x86_64-darwin10.6.0]


I see this issue in 1.9.2-p0 through the current version 1.9.2-p136 on
Mac OS X. The following code prints 'else executed'. Whereas in Ruby
1.8.x it would not execute the else statement if you called return from
within a begin block.

In summary, I would expect the following code to not print anything, but
in Ruby 1.9.2 it actually prints 'else executed':

# This code prints 'else executed'
def test_return_in_method
  begin
    return
  rescue
    puts 'rescue executed'
  else
    puts 'else executed'
  end
end
test_return_in_method
308cbef6e86dfc49cce3b2d4cf42aedc?d=identicon&s=25 SASADA Koichi (Guest)
on 2011-06-10 15:40
(Received via mailing list)
Hi,

I recognize this issue.  Matz, what do you think about it?
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2011-06-10 15:56
(Received via mailing list)
Hi,

In message "Re: [ruby-core:36926] Re: [Ruby 1.9 - Bug #4473] Calling
return within begin still executes else"
    on Fri, 10 Jun 2011 22:36:19 +0900, SASADA Koichi <ko1@atdot.net>
writes:

|I recognize this issue.  Matz, what do you think about it?

I think it should print nothing, like 1.8 does.

              matz.
308cbef6e86dfc49cce3b2d4cf42aedc?d=identicon&s=25 SASADA Koichi (Guest)
on 2011-06-10 16:02
(Received via mailing list)
(2011/06/10 22:56), Yukihiro Matsumoto wrote:
> In message "Re: [ruby-core:36926] Re: [Ruby 1.9 - Bug #4473] Calling return
within begin still executes else"
>     on Fri, 10 Jun 2011 22:36:19 +0900, SASADA Koichi <ko1@atdot.net> writes:
>
> |I recognize this issue.  Matz, what do you think about it?
>
> I think it should print nothing, like 1.8 does.

OK.  I'll check it.
This topic is locked and can not be replied to.