Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Truffle] method_added called while undefining method needed for MRI Excludes #2849

Closed
bjfish opened this issue Apr 17, 2015 · 6 comments
Closed
Assignees

Comments

@bjfish
Copy link
Contributor

bjfish commented Apr 17, 2015

Example

module TestModule

  def hello
    puts "Hello"
  end

  class TestBase64

    def self.method_added(name)
        puts "IN METHOD ADDED #{name}"
    end

      def self.include(mod)
        result = super(mod)


            puts "undef_method"
            undef_method :hello
            puts "undef_method done"
            puts "result `#{result}`"
            puts "METHODS #{self.public_instance_methods}"
           result
      end
    include TestModule
  end

end

Expected (ruby, jruby)

$ ruby sample.rb 
undef_method
undef_method done
result `TestModule::TestBase64`
METHODS [:test, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :extend, :display, :method, :public_method, :singleton_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]

Actual

./bin/jruby -X+T sample.rb 
undef_method
IN METHOD ADDED hello
undef_method done
result ``
METHODS []
@eregon eregon changed the title [Truflle] method_added called while removing method needed for MRI Excludes [Truffle] method_added called while removing method needed for MRI Excludes Apr 18, 2015
@eregon
Copy link
Member

eregon commented Apr 18, 2015

Good find! I wonder if RubySpec tests that.

@chrisseaton chrisseaton added this to the truffle-dev milestone Apr 18, 2015
@chrisseaton
Copy link
Contributor

I'll just clarify a little here - the method isn't being removed - it's being undefined. If the method were removed you would see superclass implementations, where with undefined you don't. We implement this by adding a new method is added that has the undefined flag on it. That's the cause of the bug.

@bjfish bjfish changed the title [Truffle] method_added called while removing method needed for MRI Excludes [Truffle] method_added called while undefining method needed for MRI Excludes Apr 18, 2015
@bjfish
Copy link
Contributor Author

bjfish commented Apr 18, 2015

I added a little more weird results puts "result #{result}" to the example.

@eregon eregon self-assigned this Apr 20, 2015
@eregon eregon closed this as completed in d67a173 Apr 20, 2015
@eregon
Copy link
Member

eregon commented Apr 20, 2015

Fixed, and added a spec for it.

@eregon
Copy link
Member

eregon commented Apr 20, 2015

Looking at other problems in the example.

@eregon
Copy link
Member

eregon commented Apr 20, 2015

Truffle now behaves as MRI regarding this example code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants