Skip to content

NotImplementedError raised by ObjectSpace._id2ref as called by gem 'main' #105

Closed
chuckremes opened this Issue Dec 1, 2009 · 4 comments

3 participants

@chuckremes
Rubinius member

Using a simple example from the 'main' gem documentation causes rbx to fail. Running this against the latest trunk (21874f9) generates a NotImplementedError.

This is on OSX 10.5.9 Intel.

 require 'rubygems'
 require 'main'

   ARGV.replace %w( 42 ) if ARGV.empty?

   Main {
     argument('foo'){
       required                    # this is the default
       cast :int                   # value cast to Fixnum
       validate{|foo| foo == 42}   # raises error in failure case
       description 'the foo param' # shown in --help
     }

     def run
       p params['foo'].given?
       p params['foo'].value
     end
   }

OUTPUT:

An exception occurred running a.rb
    NotImplementedError (NotImplementedError)

Backtrace:
                   ObjectSpace._id2ref at kernel/common/objectspace.rb:4
  Main::Program::ClassMethods(Class)#parameters! at (eval):2
  Main::Program::ClassMethods(Class)#parameters at (eval):4
  Main::Program::ClassMethods(Class)#argument at /Library/Ruby/Gems/1.8/gems/main-4.2.0/lib/main/program/class_methods.rb:189
         #.__script__ {} at a.rb:7
             Module(Class)#module_eval at kernel/common/eval.rb:210
  Main::Program::ClassMethods::Factory#build at /Library/Ruby/Gems/1.8/gems/main-4.2.0/lib/main/program/class_methods.rb:61
                              Main.run at /Library/Ruby/Gems/1.8/gems/main-4.2.0/lib/main/factories.rb:16
                   Kernel(Object)#Main at /Library/Ruby/Gems/1.8/gems/main-4.2.0/lib/main/factories.rb:25
                       main.__script__ at a.rb:6
    Rubinius::CompiledMethod#as_script at kernel/common/compiled_method.rb:230
           Requirer::Utils.single_load at kernel/delta/requirer.rb:236
   Requirer::Utils.load_from_extension at kernel/delta/requirer.rb:321
               Rubinius::Loader#script at kernel/loader.rb:376
                 Rubinius::Loader#main at kernel/loader.rb:485
                     Object#__script__ at kernel/loader.rb:489

@evanphx
Rubinius member
evanphx commented Dec 1, 2009

ObjectSpace._id2ref is currently unsupported. It's better to try and change libraries that use it to use a more robust mechanism anyway, as id2ref in MRI can cause a number of subtle bugs.

@chuckremes
Rubinius member

I will file a bug with the gem author. Do you have a suggestion for an alternate to id2ref that I can reference in my bug report?

@evanphx
Rubinius member
evanphx commented Dec 1, 2009

If they need to access the object as a number, use an Array and embed the index.
If they just need access to it, constant, instance variable, class variable are all acceptable.

@dbussink
Rubinius member
dbussink commented Feb 4, 2010

Added in 4477824

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.