Diagnostic and cause
СсылкаProtocol implementation violates the orphan rule
- Семейство
- topaz
- Этап
- check
- Код
TPZ5520
Причина и условия
Implementing the foreign Show protocol for the built-in int type is rejected with TPZ5520. Define a conforming record, enum, or newtype in the implementation's module.
Связанное правило · Protocol implementation violates the orphan rule →Действия
Place the implementation with the owning declaration, or define a local nominal wrapper for the external type.
Compiler phase: check.
Compiler explanation: A protocol implementation tries to connect a protocol and type that this module does not own.
Message templates are Pending. The explanation above is not an observed CLI message.
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5520]: cannot implement foreign protocol
Showfor foreign typeint(orphan rule §4.2): the protocol or the type must be defined in this module
Implementing the foreign Show protocol for the built-in int type is rejected with TPZ5520. Define a conforming record, enum, or newtype in the implementation's module.
Protocol implementation violates the orphan rule
Implementing the foreign Show protocol for the built-in int type is rejected with TPZ5520. Define a conforming record, enum, or newtype in the implementation's module.
Response
СсылкаPlace the implementation with the owning declaration, or define a local nominal wrapper for the external type.
Reproduction and verification
СсылкаRejected program
Ссылкаimpl Show<int> {function show(self) -> string { "value" }}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5520 at
example.tpz:1:11
Repaired program
Ссылкаrecord Item { value: int }impl Show<Item> {function show(value: Item) -> string { "item" }}
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.