1.8.0-preview7 block-to-super bug/change or behaviour

Hi!

Up to 1.8.0-preview6, the code below prints three lines (A, B, A).
1.8.0-preview7 prints only two (A, B).

What’s going on?

Bye,
Kero.

class A
def initialize(&block)
p “A #{block}” if block_given?
end
end

class B < A
def initialize(&block)
super() { puts “world” }
p “B #{block}” if block_given?
end
end

B.new() { puts “hello” } # results in two lines printed, OK
B.new() # nothing printed :frowning:

Kero van Gelder wrote:

Hi!

B.new() { puts “hello” } # results in two lines printed, OK
B.new() # nothing printed :frowning:

Hi,

this is what I got (with todays CVS)

···

class A
def initialize
if block_given?
p “A block”
else
p “A no-block”
end
end
end

class B < A
def initialize
super &(proc { puts “world” })
if block_given?
p “B block”
else
p “B no-block”
end
end
end

B.new() { puts “hello” }
B.new()

“A block”
“B block”
“A block”
“B no-block”

and


class A
def initialize
if block_given?
p “A block”
else
p “A no-block”
end
end
end

class B < A
def initialize
super { puts “world” }
if block_given?
p “B block”
else
p “B no-block”
end
end
end

B.new() { puts “hello” }
B.new()

“A block”
“B block”
“A no-block”
“B no-block”

/Christoph

Hi,

···

At Sun, 3 Aug 2003 20:25:23 +0900, Kero van Gelder wrote:

Up to 1.8.0-preview6, the code below prints three lines (A, B, A).
1.8.0-preview7 prints only two (A, B).

What’s going on?

Seems [ruby-talk:77654] was wrong.

Index: eval.c

RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.503
diff -u -2 -p -r1.503 eval.c
— eval.c 3 Aug 2003 10:25:32 -0000 1.503
+++ eval.c 3 Aug 2003 13:56:45 -0000
@@ -5241,5 +5241,5 @@ rb_call_super(argc, argv)
}

  • PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
  • PUSH_ITER(ruby_iter->iter || rb_block_given_p() ? ITER_PRE : ITER_NOT);
    result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3);
    POP_ITER();


Nobu Nakada

Up to 1.8.0-preview6, the code below prints three lines (A, B, A).
1.8.0-preview7 prints only two (A, B).

What’s going on?

Seems [ruby-talk:77654] was wrong.
[snip patch]

Yup, that’s it.

Thanks!
Kero.