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

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

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

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

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

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

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

    Identity and cause

    Ссылка

    TPZ5523

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

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

    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.

    Действия

    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

    Ссылка

    Repeated-bound example

    Ссылка
    example.tpzRepeated-bound exampleОткрыть песочницу →
    1. function duplicate<T: Show + Show>(value: T) -> T {
    2. value
    3. }
    Ожидаемый выводНенулевой код завершения
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    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.

    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

    Ссылка
    example.tpzRepeated bound removed
    1. function duplicate<T: Show>(value: T) -> T {
    2. value
    3. }
    Зафиксированный выводКод завершения 0
    example.tpz: types-ok (1 module)
    example.tpz: resolve-ok (1 module)
    
    $ topaz check example.tpz · Зафиксировано с Топазом 5.21.3
    Ожидаемый результат

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

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

    Наблюдаемые утверждения · Пройдено · 5.21.3

    Код завершения 0.

    Наблюдаемый стандартный вывод
    1. example.tpz: types-ok (1 module)
    2. example.tpz: resolve-ok (1 module)

    Нет вывода ошибок.

    • Пройдено · 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.

    Verification

    Ссылка

    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

    Ссылка

    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.

    Меню

    Загрузка →