rubinius/rubinius — Issue #1553: LocalJumpError: no block given
Author: emboss
Created: 2012-02-11 02:24:14+00:00
State: open

Hi,

I have code where a class can take an arbitrary object responding to each as its value,
and when I call each on the wrapping object, it should actually delegate to the inner objects
each method. Something like this:

o = Object.new
def o.each
yield 1
yield 2
end

val = SomeValue.new(o)
val.each do |e|
puts e
end

I'd expect it to print 1 and 2. The fun part is now that the implementation for delegation happens in C. In the C function for SomeValue#each, I call

rb_iterate(enumerable, rb_each, iter_i, 0);

where iter_i is defined as:

VALUE iter_i(VALUE cur, VALUE arg) { rb_yield(cur); return Qnil; }

In fact, "enumerable" would be what I called o above.
This code works in CRuby 1.9.3, but when I run it on Rubinius master, I get an error message like

Failure/Error: yield 1
LocalJumpError:
no block given

I'm not sure whether this is a bug or whether I'm doing something wrong...
It seems like the block given to val.each is not forwarded to the call on o.each, but I'm not really sure if it is supposed to either.

Thanks in advance,
Martin