[MacRuby-devel] [MacRuby] #412: Calling return in a block raises an exception

MacRuby ruby-noreply at macosforge.org
Thu Oct 29 23:56:46 PDT 2009


#412: Calling return in a block raises an exception
-------------------------------+--------------------------------------------
 Reporter:  mike@…             |       Owner:  lsansonetti@…        
     Type:  defect             |      Status:  new                  
 Priority:  blocker            |   Milestone:                       
Component:  MacRuby            |    Keywords:                       
-------------------------------+--------------------------------------------
 MacRuby 0.5 beta 1 doesn't allow calling return in a block, which works in
 1.8 and 1.9.

 {{{
 #!ruby
 def foo
   f = Proc.new { return "return from foo from inside Proc.new" }
   f.call # control leaves foo here
   return "return from foo"
 end

 def bar
   f = lambda { return "return from bar from inside lambda" }
   f.call # control does not leave bar here
   return "return from bar"
 end

 def baz
   f = proc { return "return from baz from inside proc" }
   f.call # control does not leave bar here in 1.8, but does in 1.9
   return "return from baz"
 end

 puts foo
 puts bar
 puts baz
 }}}

 ----------------------------------------

 {{{
 #!sh
 $ ruby blocks.rb
 return from foo from inside Proc.new
 return from bar
 return from baz

 $ ruby19 blocks.rb
 return from foo from inside Proc.new
 return from bar
 return from baz from inside proc

 $ macruby blocks.rb
 uncaught Objective-C/C++ exception...
 terminate called after throwing an instance of
 'RoxorReturnFromBlockException*'
 Abort trap
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/412>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list