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" }}
표준 출력 없음.기대 결과
Repaired program
링크record Item { value: int }impl Show<Item> {function show(value: Item) -> string { "item" }}
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.