This project is archived and is in readonly mode.
"".constantize returns Object
Reported by alindeman | February 14th, 2011 @ 10:06 PM
Not 100% sure if this should be considered a bug, but I found it a bit unexpected and it masked a bug in a project I was working:
ruby-1.9.2-p136 :001 > "".constantize
=> Object
ruby-1.9.2-p136 :003 > "".constantize == ::Object
=> true
I expected an error, as if I had done:
ruby-1.9.2-p136 :008 > Object.const_get("")
NameError: wrong constant name
Comments and changes to this ticket
-
Andrew White February 15th, 2011 @ 06:29 AM
- State changed from new to open
- Importance changed from to Low
I'm still not sure this is a bug - the default receiver in global namespace is Object and the existing code does take into account the possibility of an empty names array. I'll ask Jeremy Kemper since he wrote the original code.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>