• Yukihiro "Matz" Matsumoto's avatar
    Reimplement `block_given?`; ref #3841 · 388d26d7
    Yukihiro "Matz" Matsumoto authored
    Make `block_given?` to search for the top of the scope first.
    The top of the scope means either:
    
    * the top method body
    * the enclosing class body
    * the top-level
    
    The special case is the method defined by `define_method` with a
    block as in #3841. In cases like this, the method body (given by
    a block) is not considered as the top of the scope. You need to use
    `&block` in the block parameter if you want to know if a block is
    given to the method.
    
    This commit also changes the behavior of `MRB_PROC_SCOPE` flag.
    Now it is only set if the `proc` is either a class body or a method
    body defined in Ruby. It is no longer set for a block that given to
    `define_method`.
    388d26d7
kernel.c 36.4 KB