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

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

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

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

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

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

    A protocol implementation tries to connect a protocol and type that this module does not own.

    Diagnostic and cause

    Ссылка

    Protocol implementation violates the orphan rule

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

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

    Implementing the foreign Show protocol for the built-in int type is rejected with TPZ5520. Define a conforming record, enum, or newtype in the implementation's module.

    Действия

    Place the implementation with the owning declaration, or define a local nominal wrapper for the external type.

    Compiler phase: check.

    Compiler explanation: A protocol implementation tries to connect a protocol and type that this module does not own.

    Message templates are Pending. The explanation above is not an observed CLI message.

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5520]: cannot implement foreign protocol Show for foreign type int (orphan rule §4.2): the protocol or the type must be defined in this module

    Implementing the foreign Show protocol for the built-in int type is rejected with TPZ5520. Define a conforming record, enum, or newtype in the implementation's module.

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

    Protocol implementation violates the orphan rule

    Implementing the foreign Show protocol for the built-in int type is rejected with TPZ5520. Define a conforming record, enum, or newtype in the implementation's module.

    Response

    Ссылка

    Place the implementation with the owning declaration, or define a local nominal wrapper for the external type.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. impl Show<int> {
    2. function show(self) -> string { "value" }
    3. }
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ 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 { "item" }
    4. }
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Меню

    Загрузка →