Comment 7 for bug 282302

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thanks! The patch fixes metasploit, but does not bring the behavior back to 1.8.6 as described in the test case url that is provided. Eg:
class A
   @@a = 'A'
   def a=(x)
      @@a = x
   end
   def a
      @@a
   end
end

B = A.dup
B.new.a = 'B'

# should show 'B'
p A.new.a

The above still shows 'A' in patched 1.8.7, but is 'B' in 1.8.6.

The following:
class A
  Const = 'A'
  def foo
    p Const
  end
end

B = A.dup

class B
  Const = 'B'
end

p A::Const
A.new.foo
p B::Const
B.new.foo

This should display:
"A"
"A"
"B"
"A"

But on patched 1.8.7 I got:
/tmp/35116b.rb:11: warning: already initialized constant Const
"A"
"A"
"B"
"B"

That said, unpatched 1.8.7 still shows 'A' in the first test, but the second results in:
/tmp/35116b.rb:11: warning: already initialized constant Const
"A"
"A"
"B"
/tmp/35116b.rb:4:in `foo': uninitialized constant Const (NameError)
 from /tmp/35116b.rb:19

So clearly, the patch partially addresses this test case. Does the stable ruby snapshot work the same as 1.8.6 in the above test cases?