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

    TPZ5521: Duplicate protocol implementation

    The same type already conforms to the same protocol.

    Diagnostic and cause

    Link

    Duplicate protocol implementation

    Family
    topaz
    Phase
    check
    Code
    TPZ5521

    Cause and conditions

    Each nominal type has at most one conformance to a given protocol. Repeating a derives entry or adding another implementation of the same conformance is rejected with TPZ5521.

    Response

    Keep one implementation of the protocol for that type. Remove the duplicate derives entry or manual implementation.

    Source evidence

    Compiler phase: check.

    Compiler explanation: The same type already conforms to the same protocol.

    Message templates. The marker ⟨value⟩ stands for text computed for the reported program.

    • ⟨value⟩ conformance to ⟨value⟩ ⟨value⟩; a conformance must be unique Source
    • ⟨value⟩ already conforms to ⟨value⟩ ⟨value⟩; a conformance must be unique Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5521]: Item conformance to Show is derived more than once; a conformance must be unique

    Each nominal type has at most one conformance to a given protocol. Repeating a derives entry or adding another implementation of the same conformance is rejected with TPZ5521.

    Rulediagnostics.tpz5521.p5.rule

    Duplicate protocol implementation

    Each nominal type has at most one conformance to a given protocol. Repeating a derives entry or adding another implementation of the same conformance is rejected with TPZ5521.

    Source evidence

    Response

    Link

    Keep one implementation of the protocol for that type. Remove the duplicate derives entry or manual implementation.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. record Item derives Show, Show { value: int }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5521 diagnostic-tpz5521 at example.tpz:1:27
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. record Item derives Show { value: int }
    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