From: Satoshi Shiba Date: 2011-12-23T17:10:06+09:00 Subject: [ruby-core:41790] Re: Breaking while loading Nikolai Weibull wrote: > 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. > Sorry, I misunderstood this problem and I can't judge whether this is a bug or not. It would be true that break can't cross load. In load method, Ruby runtime checks break and throws LocalJumpError.