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] Error in extending Module #2804

Closed
bjfish opened this issue Apr 4, 2015 · 8 comments
Closed

[Truffle] Error in extending Module #2804

bjfish opened this issue Apr 4, 2015 · 8 comments
Assignees
Milestone

Comments

@bjfish
Copy link
Contributor

bjfish commented Apr 4, 2015

Example Code

module Module1

  def self.extend_object(cl)
    super
    cl.bind(self)
  end

  def bind(cl)
    self.module_eval %[
      def self.included(mod)
        mod.extend Module1
      end
    ]
  end

  def Raise(err = nil, *rest)
    puts "Raise"
  end

end

module Module2
  extend Module1
end

class Example
  include Module2

  def raise_error
    Example.Raise
  end

end

Example.new.send(:raise_error)

Error

matrix.rb:31:in `method_missing': undefined method `Raise' for Class (NoMethodError)
    from matrix.rb:31:in `raise_error'
    from matrix.rb:36:in `send'
    from matrix.rb:36:in `<main>'

Expected (ruby,jruby)

Raise

Example is used in stdlib matrix

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

A smaller test case is

module Module1

  def self.extend_object(cl)
    puts 'here'
  end

end

module Module2
  extend Module1
end

The problem is that we implement extend as doing the actual extension, where it should call extend_object, which does it.

There are loads of methods like this - included is another example - that we need to implement.

@bjfish
Copy link
Contributor Author

bjfish commented Apr 6, 2015

TODO untag failing matrix specs once this is ready e2d3abd

@bjfish
Copy link
Contributor Author

bjfish commented Apr 8, 2015

Singleton should work once we have extend_object. Current failing example:

module Example

  class << Example

    private

    undef_method :extend_object

  end

end

Error:

singleton.rb:7:in `undef_method': undefined method `extend_object' for #<Class:0xe0> (NoMethodError)
    from singleton.rb:7:in `(singleton-def)'

@chrisseaton
Copy link
Contributor

@eregon please take a look since you know the module system better than most

@eregon
Copy link
Member

eregon commented Apr 8, 2015

This should probably use extended and the module_eval seems unnecessary, but we have to support these semantics anyway.
I'll have a quick look tomorrow.

@eregon eregon closed this as completed in 2bd3f4c Apr 9, 2015
@eregon
Copy link
Member

eregon commented Apr 9, 2015

Fixed.

eregon added a commit that referenced this issue Apr 9, 2015
@eregon
Copy link
Member

eregon commented Apr 9, 2015

Also untagged matrix in e2c64c6, thanks for you work!

@bjfish
Copy link
Contributor Author

bjfish commented Apr 9, 2015

@eregon 👍 thanks!

@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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