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

    TPZ5008: Redeclaration

    A scope declares the same value name more than once.

    Diagnostic and cause

    Link

    Redeclaration

    Family
    topaz
    Phase
    check
    Code
    TPZ5008

    Cause and conditions

    A protocol implementation must not define the same method twice. A duplicate method is rejected with TPZ5008 at the later method name.

    Response

    Rename or remove the later duplicate. Use a nested scope when a separate local binding is intended.

    Source evidence

    Compiler phase: check/runtime.

    Compiler explanation: A scope declares the same value name more than once.

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

    • duplicate concurrent arm ⟨value⟩ Source
    • field ⟨value⟩ is given twice in ⟨value⟩ Source
    • record field ⟨value⟩ is declared twice in ⟨value⟩ Source
    • method ⟨value⟩ is already declared in protocol ⟨value⟩ Source
    • ⟨value⟩ is a builtin protocol and cannot be redeclared Source
    • protocol ⟨value⟩ is already declared Source
    • nominal record pattern field ⟨value⟩ is specified more than once Source
    • ⟨value⟩ is already declared in this scope Source
    • method ⟨value⟩ is implemented twice in impl ⟨value⟩<⟨value⟩> Source
    • method ⟨value⟩ is already defined for ⟨value⟩ Source
    • ⟨value⟩ is already declared in this scope Source
    • ⟨value⟩ is already declared in this scope Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5008]: method show is implemented twice in impl Show<Item>

    A protocol implementation must not define the same method twice. A duplicate method is rejected with TPZ5008 at the later method name.

    Rulediagnostics.tpz5008.p5.rule

    A protocol implementation defines each method once

    A protocol implementation must not define the same method twice. A duplicate method is rejected with TPZ5008 at the later method name.

    Source evidence

    Response

    Link

    Rename or remove the later duplicate. Use a nested scope when a separate local binding is intended.

    Reproduction and verification

    Link

    Rejected program

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

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5008 diagnostic-tpz5008 at example.tpz:4:12
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. record Item { value: int }
    2. impl Show<Item> {
    3. function show(value: Item) -> string { "first" }
    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