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.
This code should print 42, but doesn't
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:
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.