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

singleton class cannot call methods of regular class #3509

Closed
christopheraue opened this issue Mar 14, 2017 · 0 comments
Closed

singleton class cannot call methods of regular class #3509

christopheraue opened this issue Mar 14, 2017 · 0 comments

Comments

@christopheraue
Copy link
Contributor

$ cat singleton_class.mrb 
class Klass
  def self.meth
    :result
  end
end

o = Klass.new
# o.singleton_class.singleton_class

p o.singleton_class.meth

Running this raises an error:

$ ./mruby singleton_class.mrb 
trace:
        [0] singleton_class.mrb:10
NoMethodError: undefined method 'meth' for #<Class:#<Klass:0x213e350>>

Explicitly accessing the singleton class of the singleton class (uncommenting the commented line in singleton_class.mrb) prevents the issue and prints :result.

@matz matz closed this as completed in fa502b4 Mar 18, 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

1 participant