Skip to content

Compiled method bodies do not scope defn/defs correctly #1239

@headius

Description

@headius

Moved from http://jira.codehaus.org/browse/JRUBY-7128, reported by @nirvdrum.

This might be a bug in rspec-expectations, but I'm unable to force JIT my app due to a bad :remove_method call. Specifically, in my rspec (2.13.0) setup, I've tried to disable the old should syntax with something like the following:

RSpec.configure do |config|
  config.expect_with :rspec do |c|
    c.syntax = :expect
  end
end

This causes rspec to execute this method:

def self.disable_deprecated_should
  return unless deprecated_should_enabled?

  remove_method :should
  remove_method :should_not

  self.deprecated_should_enabled = false
end

And when that's executed things blow up like so:

 ~/d/w/mogotest /master> rspec spec/models/user_spec.rb 
NameError: method 'should' not defined in RSpec::Expectations::ExpectationTarget
              remove_method at org/jruby/RubyModule.java:2331
  disable_deprecated_should at /home/nirvdrum/.rbenv/versions/jruby-1.7.2/lib/ruby/gems/shared/gems/rspec-expectations-2.13.0/lib/rspec/expectations/expectation_target.rb:71
             disable_should at /home/nirvdrum/.rbenv/versions/jruby-1.7.2/lib/ruby/gems/shared/gems/rspec-expectations-2.13.0/lib/rspec/expectations/syntax.rb:74
                    syntax= at /home/nirvdrum/.rbenv/versions/jruby-1.7.2/lib/ruby/gems/shared/gems/rspec-expectations-2.13.0/lib/rspec/matchers/configuration.rb:29

I'm raising the issue because I don't see this behavior when I don't force JIT. I don't know if it has to do with loading semantics or if force JIT should be resilient to errors like this. It could also just be an rspec bug that I can take up with them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions