Improve error reporting for 'deriving' (Trac #2604)