Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Диагностика TPZ5008

    A scope declares the same value name more than once.

    Diagnostic and cause

    Ссылка

    Redeclaration

    Семейство
    topaz
    Этап
    check
    Код
    TPZ5008

    Причина и условия

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

    Действия

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

    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.

    Правилоdiagnostics.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.

    Response

    Ссылка

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

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. record Item { value: int }
    2. impl Show<Item> {
    3. function show(value: Item) -> string { "first" }
    4. function show(value: Item) -> string { "second" }
    5. }
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения check. Ненулевой код завершения.

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. record Item { value: int }
    2. impl Show<Item> {
    3. function show(value: Item) -> string { "first" }
    4. }
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Проверка принимает программу. Код завершения 0.

    Меню

    Загрузка →