Skip to content

Bad nonlocal return with re-wrapped define_method block #2833

@headius

Description

@headius

This example should print out :here but it does not, because the non-local return in the define_method block causes the test method to return early.

class Foo
  def define(name, &block)
    class << self; self; end.send(:define_method, name, block)
  end

  def define2(name, &block)
    define(name, &block)
  end

  def test
    define(:foo) { return 1 }
    call_foo
    puts :here
  end

  def call_foo
    foo
  end
end

Foo.new.test

This is causing mocha's test suite to bail out prematurely.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions