Issue #6434 has been updated by trans (Thomas Sawyer).


I see. It's not intuitive, obviously, but I suppose it makes sense for how Ruby handles implicit yield in general. Nonetheless, wouldn't it be better if this did not apply when a explicit block argument is used?

  # would pass block implicitly
  def foo
    super
  end

  # would NOT pass block implicitly
  def foo(&block)
    super
  end

In any case I discovered the use of `&nil` as a work around prior to posting this and that does the trick. Thanks.

----------------------------------------
Bug #6434: Block passed implicitly via super
https://bugs.ruby-lang.org/issues/6434#change-26632

Author: trans (Thomas Sawyer)
Status: Rejected
Priority: Normal
Assignee: 
Category: core
Target version: 1.9.3
ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]


=begin
Block is being passed via super implicitly even though the method is explicit and does not pass the block when calling super.

    class H < Hash
      def initialize(default=nil, &block)
        super(default)
      end
    end
    H.new(0){}

    ArgumentError: wrong number of arguments
    from (pry):3:in `initialize'

Hash#initialize doesn't allow both a default argument and a default_proc, which is the cause of this error. Which means the block is being passed up even though it should not be.
=end


-- 
http://bugs.ruby-lang.org/