Forum: Ruby-core NameError#name and nested constants

2d27b53e2eeb6a053552332020628029?d=identicon&s=25 unknown (Guest)
on 2014-08-05 16:52
(Received via mailing list)
Issue #10108 has been updated by Robin Dupret.

Yes, a full qualified name seems more appropriate and more consistent
with the output of the error message. Thanks for the quick answer !

Feature #10108: NameError#name and nested constants

* Author: Robin Dupret
* Status: Open
* Priority: Normal
* Assignee:
* Category: core
* Target version:

We wanted to bring a discussion around the behavior of NameError#name
with nested constants. The result can be quite unexpected when we are
dealing with them. For instance:

rescue NameError => e # => :PHI

Having Math::PHI seems more expected. Rubinius works the same way as MRI
while JRuby will return a symbol with the full path (i.e.
`:"Math::PHI"`). Is there any reason why you are returning only the last
part of the missing "path" ? At the very least, there is a documentation
problem since `NameError#name`'s documentation states:

~~~    ->  string or nil

but it always return a symbol.

Have a nice day !
This topic is locked and can not be replied to.