From: Nikolai Weibull Date: 2011-12-23T16:01:14+09:00 Subject: [ruby-core:41789] Re: Breaking while loading On Fri, Dec 23, 2011 at 07:17, Satoshi Shiba wrote: > I can't judge whether this is a bug for Ruby runtime or not. > However, I can show reasons why LocalJumpError has occurred. > > Reasons why LocalJumpError has occurred are consisting of followings. > > 1:"break" in proc objects cause LocalJumpError. > 2:In your example, $block in A#enum is a proc object > ��and $block in A#enum causes "break". It���s not quite that simple. If you move contents of b.rb to a method b in a.rb and call it instead of loading b.rb everything works as expected. It seems like the break can���t cross load. You can work around this limitation/bug by postponing execution of the contents of b.rb until after load has returned, but I still want to know if this is a bug or not. a.rb: def back_to_a(&block) $a = block end class A include Enumerable def each(&block) $block = block load 'b.rb', true $a.call self end end p A.new.take_while{ |i| i < 3 } b.rb: back_to_a do $block.call 1 $block.call 2 $block.call 3 end