avram icon indicating copy to clipboard operation
avram copied to clipboard

Avram::NeedyInitializer#inherit_needs error message is less than helpful.

Open BrucePerens opened this issue 4 years ago • 2 comments

This error message is less than helpful. The real error is "that class should be abstract".

crystal spec
Showing last frame. Use --error-trace for full trace.

There was a problem expanding macro 'inherit_needs'

Code in macro 'inherited'

Called macro defined in lib/avram/src/avram/needy_initializer_and_delete_methods.cr:15:3

 15 | macro inherit_needs

Which expanded to:

 > 4 | 
 > 5 |     {% if [email protected]? %}
 > 6 |       {% for type_declaration in @type.ancestors.first.constant :OPERATION_NEEDS %}
                                                              ^-------
Error: BUG: DeleteHierarchical(Forum) has no types

BrucePerens avatar Feb 10 '21 19:02 BrucePerens

Can you paste a code snippet of how to re-create this error?

jwoertink avatar Feb 10 '21 22:02 jwoertink

It's something like this:

class HierarchicalDeleteOperation(T) < Avram::DeleteOperation(T)
end

class DeleteCompany < HierarchicalDeleteOperation(Company)
end

DeleteCompany.new(Company.new).delete!

If you change HierarchicalDeleteOperation(T) to be abstract, there is no message.

BrucePerens avatar Feb 11 '21 03:02 BrucePerens