Problem with Struct in Ruby 1.8.0

I have a problem with class Struct in Ruby 1.8.0.

The following lines are ok in Ruby 1.6.8, but not
in 1.8.0.

puts defined? File::Stat
p Struct.new(File.name, ‘key’).new
p Struct.new(File::Stat.name, ‘key’).new

Output in ruby 1.6.8 (2002-12-24) [i386-linux-gnu]

constant
#<Struct::File key=nil>
#<Struct::File::Stat key=nil>

Output in ruby 1.8.0 (2003-02-08) [i686-linux]

constant
#<Struct::File key=nil>
t:3:in `new’: identifier File::Stat needs to be constant (NameError)
from t:3

Is this new behaviour intended?

Klaus Spreckelsen

Hi,

···

In message “Problem with Struct in Ruby 1.8.0” on 03/03/01, “Klaus Spreckelsen,NB 7/129,22329” ks@tp1.ruhr-uni-bochum.de writes:

I have a problem with class Struct in Ruby 1.8.0.

The following lines are ok in Ruby 1.6.8, but not
in 1.8.0.

puts defined? File::Stat
p Struct.new(File.name, ‘key’).new
p Struct.new(File::Stat.name, ‘key’).new

Ah, you were defining Struct::“File::Stat” which is a Struct class
with name “File::Stat”. This is just invalid class name. You can’t
access it via Struct::File::Stat. I considered it a bug and fixed in
1.8.0

						matz.