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

    TPZ5523: Duplicate protocol bound

    Explains a repeated protocol bound on one function type parameter and its correction.

    Identity and cause

    Link

    TPZ5523

    Family
    topaz
    Phase
    check
    Code
    TPZ5523

    Cause and conditions

    Each type parameter names a resolved protocol identity once. Repeating that identity produces TPZ5523, including through namespace qualification or aliases. A distinct protocol declaration remains a different requirement even when another module gives it the same name.

    Response

    Source evidence

    A function declaration names the same protocol more than once in the bounds of one type parameter. The checker compares the protocol name together with the type-parameter index. Repetition on one parameter is distinct from using that protocol on two different parameters. It attaches TPZ5523 to the repeated bound.

    Rejected example

    Link

    Repeated-bound example

    Link
    example.tpzRepeated-bound exampleOpen in Playground
    1. function duplicate<T: Show + Show>(value: T) -> T {
    2. value
    3. }
    Expected outputNonzero exit
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5523 repeated-protocol-bound at example.tpz:1:30

    TPZ5523 points to the second Show at example.tpz:1:30. Each later occurrence for the same type parameter is diagnosed. Checking continues, so other applicable diagnostics may also appear. Remove the repeated bound to correct this program. The earlier receipt predates the location assertion; CI must execute this revision.

    Observed: The authored exit and diagnostic-cause assertions passed. The primary-location assertion and additional-diagnostics policy remain pending. Recorded with Topaz 5.21.3 in run 42147883818 at 2026-11-06T02:04:56.5052224Z. Document source: 1d6f9265d918.

    Source evidence

    Fix

    Link

    Keep one occurrence of each required protocol. If additional, distinct protocols are required, retain those bounds. This correction removes repetition; the repaired example checks the complete program.

    Repeated bound removed

    Link
    example.tpzRepeated bound removed
    1. function duplicate<T: Show>(value: T) -> T {
    2. value
    3. }
    Recorded outputexit 0
    example.tpz: types-ok (1 module)
    example.tpz: resolve-ok (1 module)
    
    $ topaz check example.tpz · recorded with topaz 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Observed assertions · passed · 5.21.3

    Exit code 0.

    Observed stdout
    1. example.tpz: types-ok (1 module)
    2. example.tpz: resolve-ok (1 module)

    No stderr.

    • Passed · expected 0; observed 0

    Acceptance of this corrected complete program is a separate check.

    Observed: The authored assertions passed. Recorded with Topaz 5.21.3 in run 42147883818 at 2026-11-06T02:04:56.5498911Z. Document source: 1d6f9265d918.

    Source evidence

    Verification

    Link

    The examples reuse the exact source, independent expectations, and product observations shown in Functions and generics. The required primary location and additional-diagnostic policy remain Pending.

    Related rules

    Link

    Functions and generics

    Exported functions also have restrictions on exposing module-local protocols. Those are reported separately as TPZ5524 and are not repaired merely by removing duplicates.

    Menu

    Download