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

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

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

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

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

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

    Every alternative of a binding or-pattern must bind the same set of names.

    Diagnostic and cause

    Ссылка

    Or-pattern alternatives bind different names

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

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

    During checking, TPZ5710 reports different name sets in alternatives of an or-pattern. The or-pattern binding rule defines the binding requirement.

    Действия

    Use Some(_) | None() when the arm does not need a binding. Otherwise bind the same names in every alternative or write separate arms.

    Compiler phase: check.

    Compiler explanation: Every alternative of a binding or-pattern must bind the same set of names.

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

    • or-pattern alternatives must bind the same names — ⟨value⟩ is bound in one alternative but not another Source

    During checking, TPZ5710 reports different name sets in alternatives of an or-pattern. The or-pattern binding rule defines the binding requirement.

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

    Different names in or-pattern alternatives

    During checking, TPZ5710 reports different name sets in alternatives of an or-pattern. The or-pattern binding rule defines the binding requirement.

    Response

    Ссылка

    Use Some(_) | None() when the arm does not need a binding. Otherwise bind the same names in every alternative or write separate arms.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. function read(value: Option<int>) -> int {
    2. match (value) {
    3. case Some(item) | None() => 0
    4. }
    5. }
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    • TPZ5710 →

      or-pattern-alternatives-bind-different-name-sets at example.tpz:3:10

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. function read(value: Option<int>) -> int {
    2. match (value) {
    3. case Some(_) | None() => 0
    4. }
    5. }
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Меню

    Загрузка →