rb_cv_set defines class var but doesn't?

T

Tim Hunter

I'm using rb_cv_set in a C extension to set the value of a class
variable. Via gdb I can see that rb_cv_set successfully creates the
variable. The rb_cvar_defined function returns Qtrue and a subsequent
call to rb_cv_get returns the correct value. From the C side, everything
is copacetic.

From Ruby, however, things are squirrely. Using class_eval I can see
the variable:

MyClass.class_eval { p class_variables }

shows ["@@_tmpnam_"] as expected. However,

MyClass.class_eval { x = @@_tmpnam_ }

raises NameError: "uninitialized class variable @@_tmpnam_ in MyClass".

MyClass.class_eval { p defined? @@_tmpnam_ }

shows "nil".

I'm running 1.8.6 patchlevel 114 on Kubuntu Gutsy.

This works as expected with Ruby 1.9.0-1.

Is this just a bug in 1.8.6? Is there another way I can inspect the
value of @@_tmpnam_ in 1.8.6?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top