Diagnostic and cause
LinkMissing protocol conformance
- Family
- topaz
- Phase
- check
- Code
TPZ5522
Cause and conditions
A concrete type argument must satisfy every declared protocol bound. Calling a Show-bounded function with a record lacking Show conformance is rejected with TPZ5522.
Related rule: Missing protocol conformanceResponse
Derive or implement the required protocol when supported. For a generic function, add the bound that its body or callers require.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 828-842 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1038-1038 - compiler/crates/topaz_self_frontend/topaz/checker/expression_core.tpz at
151141d7bb44· 1373-1373 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 2325-2325 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 2307-2329
Compiler phase: check.
Compiler explanation: A protocol call or generic protocol bound requires a conformance the receiver type does not have.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5522]:
Userdoes not satisfy protocol boundShow
A concrete type argument must satisfy every declared protocol bound. Calling a Show-bounded function with a record lacking Show conformance is rejected with TPZ5522.
Missing protocol conformance
A concrete type argument must satisfy every declared protocol bound. Calling a Show-bounded function with a record lacking Show conformance is rejected with TPZ5522.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 2307-2329
Response
LinkDerive or implement the required protocol when supported. For a generic function, add the bound that its body or callers require.
Reproduction and verification
LinkRejected program
Linkrecord User { name: string }function render<T: Show>(value: T) -> string { Show.show(value) }let result = render(User { name: "Ada" })
No stdout.
Expected result
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 2307-2329
Repaired program
Linkrecord User derives Show { name: string }function render<T: Show>(value: T) -> string { Show.show(value) }let result = render(User { name: "Ada" })
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 2307-2329