Project

General

Profile

« Previous | Next » 

Revision 628e4327

Added by ko1 (Koichi Sasada) over 2 years ago

fix NameError message

The following code produces two NameErrors respectively
and they are independent, but the second one can show
private constant message because of first NameError.

class C
  class PrivateClass; end
  private_constant :PrivateClass
end

begin
  eval('class C::PrivateClass; end')
rescue => e
  p e
end

begin
  Object.const_get 'Foo'
rescue => e
  p e
end

  #<NameError: private constant C::PrivateClass referenced>
  #<NameError: private constant C::Foo referenced>
  #=> should be #<NameError: uninitialized constant Foo>

It fails the test-all tests with
make test-all TESTS='ruby/class ruby/parse --seed=58891 -v.

The reason is clear miss from https://github.com/ruby/ruby/commit/7387c08373a