This project is archived and is in readonly mode.
Unhelpful error message when referencing missing constants in eigenclasses
Reported by Rich Meyers | June 21st, 2010 @ 06:08 PM
Referencing undefined/missing constants when in eigenclasses results in an error message that does not mention true problem (undefined/missing constant) nor which constant was referenced, as in the following code:
require 'config/boot'
require 'config/environment'
class Base
class << self
def foo
# ArgumentError: Anonymous modules have no name to be referenced by
# vendor/rails/activesupport/lib/active_support/dependencies.rb:585:in `to_constant_name'
# vendor/rails/activesupport/lib/active_support/dependencies.rb:391:in `qualified_name_for'
# vendor/rails/activesupport/lib/active_support/dependencies.rb:104:in `const_missing'
# rails 2.3.8
Missing
end
end
end
class Sub < Base
# Can call foo directly from base, but this is the usual use case
foo
end
One of const_missing, qualified_name_for or to_constant_name ought to account for the current class being an eigenclass and raise an exception with a sensible message.
Attached patch fixes the issue, although the fix could likely be improved.
Comments and changes to this ticket
-
José Valim June 22nd, 2010 @ 04:48 PM
Thanks for the patch mate, but could you please add, with the patch, a test reproducing this issue to ensure we won't have a regression?
-
José Valim June 22nd, 2010 @ 04:53 PM
- Assigned user set to Xavier Noria
-
Xavier Noria June 26th, 2010 @ 10:39 AM
- State changed from new to open
- Importance changed from to Low
I have had a look at this, it happens in 2.3 but not in master, so it has definitely low priority.
Could have a look at it again if a complete patch with tests is provided.
-
Xavier Noria June 30th, 2010 @ 12:15 AM
- State changed from open to wontfix
Closing this by now to cleanup remaining tickets for RC. Please feel free to reopen with a patch.
-
Rich Meyers August 17th, 2010 @ 09:46 PM
I was hoping that the solution could be implemented better. Catching ArgumentError like the patch I attached does is not something I want to see in rails.
Is work on rails 2.3 stopped?
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>