Diagnostic and cause
LinkProtocol cannot be derived for this type
- Family
- topaz
- Phase
- check
- Code
TPZ5530
Cause and conditions
Deriving Eq requires every contained field type to support equality. A function-valued field prevents Eq derivation and produces TPZ5530.
Related rule: Protocol cannot be derived for this typeResponse
Use a supported derives protocol and compatible stored types. Remove the clause or write an admitted manual implementation where that protocol permits one.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 863-872 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 302-302 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 207-224 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 317-368
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.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 207-224 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 317-368
Response
LinkUse 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
LinkRejected program
Linkrecord Callback derives Eq { action: () -> int }
No stdout.
Expected result
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 207-224 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 317-368
Repaired program
Linkrecord Callback derives Eq { action: int }
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 207-224 - compiler/crates/topaz_self_frontend/topaz/checker/diagnostics_derives.tpz at
151141d7bb44· 317-368