[MacRuby] #1257: Calling super doesn't pass along the block
MacRuby
ruby-noreply at macosforge.org
Tue May 3 17:00:21 PDT 2011
#1257: Calling super doesn't pass along the block
------------------------------------+---------------------------------------
Reporter: james@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby | Keywords: super blocks mechanize
------------------------------------+---------------------------------------
When you call super in macruby, it doesn't pass any blocks along; which is
counter to the behavior in other rubys and causes gems that use this
functionality, such as Mechanize (see #1218, #1182) to fail.
See the following code:
{{{
class Foo
attr_accessor :a, :b
def initialize(a)
@a = a
yield self if block_given?
end
end
class Bar < Foo
attr_accessor :c
def initialize(a, c)
@c = c
super(c)
end
end
# MacRuby 0.10
Bar.new(1, 3) {|foo| foo.b = 2} #=> <Bar:0x2003e80a0 @c=3 @a=3>
# Ruby 1.9.2
Bar.new(1, 3) {|foo| foo.b = 2} #=> <Bar:0x000001009b85b0 @c=3, @a=3,
@b=2>
}}}
For those interested, I made a patch to Mechanize 2.0.pre.2
https://github.com/jamesdaniels/mechanize
--
Ticket URL: <http://www.macruby.org/trac/ticket/1257>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list