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

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

Comments

Projects
None yet
3 participants
@chuckremes
Member

chuckremes commented Dec 1, 2009

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

This comment has been minimized.

Show comment
Hide comment
@evanphx

evanphx Dec 1, 2009

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@chuckremes

chuckremes Dec 1, 2009

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?

Member

chuckremes commented Dec 1, 2009

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

This comment has been minimized.

Show comment
Hide comment
@evanphx

evanphx Dec 1, 2009

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@dbussink

dbussink Feb 4, 2010

Member

Added in 4477824

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