Fixnum#public_methods raises TypeError #2107

Merged
merged 2 commits into from Dec 28, 2012

Projects

None yet

2 participants

@rf-
~ ruby --version
rubinius 2.0.0.rc1 (1.8.7 8c11e951 yyyy-mm-dd JI) [x86_64-apple-darwin12.2.1]
~ ruby -e '10.public_methods'
An exception occurred evaluating command line code
    no singleton class available for a Fixnum (TypeError)

Backtrace:
        Rubinius::Type.object_singleton_class at kernel/bootstrap/type.rb:23
      Kernel(Fixnum)#public_singleton_methods at kernel/common/kernel.rb:511
                Kernel(Fixnum)#public_methods at kernel/common/kernel.rb:507
                     { } in Object#__script__ at -e:1
  Rubinius::BlockEnvironment#call_on_instance at kernel/common/block_environment.rb:75
                Kernel(Rubinius::Loader)#eval at kernel/common/eval.rb:75
                       Rubinius::Loader#evals at kernel/loader.rb:584
                        Rubinius::Loader#main at kernel/loader.rb:815

The same thing happens in 1.9 mode. methods, private_methods, and protected_methods work fine.

@dbussink
Rubinius member

Regarding the spec question posed in IRC, it means the spec should go in spec/ruby/core/kernel/public_methods_spec.rb, since that's where behavior of this method is described.

@dbussink dbussink commented on an outdated diff Dec 28, 2012
spec/ruby/core/kernel/public_methods_spec.rb
@@ -28,6 +28,10 @@
m.extend(KernelSpecs::Methods::MetaclassMethods)
m.public_methods.should include('peekaboo')
end
+
+ it "works on immediate values" do
@dbussink
dbussink Dec 28, 2012

Please use other wording than it "works", since that doesn't really convey any meaning. Probably something like it "returns public methods for immediates", since that describes what it does.

rf- added some commits Dec 28, 2012
@rf- rf- Add failing spec for Fixnum#public_methods 1b8df69
@rf- rf- Override public_singleton_methods in ImmediateValue
This fixes an issue where calling public_methods on a Fixnum would call
Kernel#public_singleton_methods and raise a TypeError.
b59b93e
@dbussink dbussink merged commit b17f42e into rubinius:master Dec 28, 2012

1 check was pending

Details default The Travis build is in progress
@rf- rf- deleted the unknown repository branch Dec 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment