Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ5520: Protocol implementation violates the orphan rule

    A protocol implementation tries to connect a protocol and type that this module does not own.

    Diagnostic and cause

    Link

    Protocol implementation violates the orphan rule

    Family
    topaz
    Phase
    check
    Code
    TPZ5520

    Cause and conditions

    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.

    Source evidence

    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 Show for foreign type int (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.

    Rulediagnostics.tpz5520.p5.rule

    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.

    Source evidence

    Response

    Link

    Place the implementation with the owning declaration, or define a local nominal wrapper for the external type.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. impl Show<int> {
    2. function show(self) -> string { "value" }
    3. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5520 diagnostic-tpz5520 at example.tpz:1:11
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. record Item { value: int }
    2. impl Show<Item> {
    3. function show(value: Item) -> string { "item" }
    4. }
    Expected outputexit 0
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Source evidence

    Menu

    Download