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

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

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

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

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

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

    A protocol call or generic protocol bound requires a conformance the receiver type does not have.

    Diagnostic and cause

    Ссылка

    Missing protocol conformance

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

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

    A concrete type argument must satisfy every declared protocol bound. Calling a Show-bounded function with a record lacking Show conformance is rejected with TPZ5522.

    Действия

    Derive or implement the required protocol when supported. For a generic function, add the bound that its body or callers require.

    Compiler phase: check.

    Compiler explanation: A protocol call or generic protocol bound requires a conformance the receiver type does not have.

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

    • protocol ⟨value⟩ has no method ⟨value⟩ Source
    • ⟨value⟩ does not satisfy protocol bound ⟨value⟩ Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5522]: User does not satisfy protocol bound Show

    A concrete type argument must satisfy every declared protocol bound. Calling a Show-bounded function with a record lacking Show conformance is rejected with TPZ5522.

    Правилоdiagnostics.tpz5522.p5.rule

    Missing protocol conformance

    A concrete type argument must satisfy every declared protocol bound. Calling a Show-bounded function with a record lacking Show conformance is rejected with TPZ5522.

    Response

    Ссылка

    Derive or implement the required protocol when supported. For a generic function, add the bound that its body or callers require.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. record User { name: string }
    2. function render<T: Show>(value: T) -> string { Show.show(value) }
    3. let result = render(User { name: "Ada" })
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. record User derives Show { name: string }
    2. function render<T: Show>(value: T) -> string { Show.show(value) }
    3. let result = render(User { name: "Ada" })
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Меню

    Загрузка →