Diagnostic and cause
СсылкаMissing protocol conformance
- Семейство
- topaz
- Этап
- check
- Код
TPZ5522
Причина и условия
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 →Действия
Derive or implement the required protocol when supported. For a generic function, add the bound that its body or callers require.
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.
- protocol
⟨value⟩has no method⟨value⟩Source ⟨value⟩does not satisfy protocol bound⟨value⟩Source
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.
Response
СсылкаDerive or implement the required protocol when supported. For a generic function, add the bound that its body or callers require.
Reproduction and verification
СсылкаRejected program
Ссылкаrecord User { name: string }function render<T: Show>(value: T) -> string { Show.show(value) }let result = render(User { name: "Ada" })
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5522 at
example.tpz:3:14
Repaired program
Ссылкаrecord User derives Show { name: string }function render<T: Show>(value: T) -> string { Show.show(value) }let result = render(User { name: "Ada" })
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.