MagLev / maglev

GemStone Maglev Ruby Repository
http://maglev.github.io
517 stars 41 forks source link

&block argument references implicit block #69

Closed timfel closed 13 years ago

timfel commented 13 years ago

This code should print 42, but doesn't

def foo(&block)
  block = proc { 0 }
  yield
end
p bar { 42 }

What happens is, that the &block parameter points to the stack location of the implicit block, so the assignment overwrites that location and the implicit block is lost. The semantics of &block are really:

def foo(block = (Proc.new if block_given?))
  block = proc { nil.pause }
  yield
end

I have already submitted a rubyspec for this, which we will fail.

This specific problem causes us to go into an infinite loop when trying to run tilt/nokokgiri.rb:19 (#evaluate), causing spec failures on Sinatra when using layouts with Nokogiri.

timfel commented 13 years ago

Fixed in magtrac, will be in next release.