Diagnostic and cause
СсылкаProtocol cannot be derived for this type
- Семейство
- topaz
- Этап
- check
- Код
TPZ5530
Причина и условия
Deriving Eq requires every contained field type to support equality. A function-valued field prevents Eq derivation and produces TPZ5530.
Связанное правило · Protocol cannot be derived for this type →Действия
Use a supported derives protocol and compatible stored types. Remove the clause or write an admitted manual implementation where that protocol permits one.
Compiler phase: check.
Compiler explanation: A derives clause asks for generated protocol behavior that this type's fields or payloads cannot support.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- unknown protocol
⟨value⟩inderivesfor⟨value⟩; derivable protocols areEq,Order,Show,JSONSource
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5530]: cannot derive
EqforCallback: fieldactionhas a non-comparable type
Deriving Eq requires every contained field type to support equality. A function-valued field prevents Eq derivation and produces TPZ5530.
Protocol cannot be derived for this type
Deriving Eq requires every contained field type to support equality. A function-valued field prevents Eq derivation and produces TPZ5530.
Response
СсылкаUse a supported derives protocol and compatible stored types. Remove the clause or write an admitted manual implementation where that protocol permits one.
Reproduction and verification
СсылкаRejected program
Ссылкаrecord Callback derives Eq { action: () -> int }
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5530 at
example.tpz:1:25
Repaired program
Ссылкаrecord Callback derives Eq { action: int }
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.