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(_ 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.
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(_ 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
Ссылкаfunction read(value: Option<int>) -> int {match (value) {case Some(item) | None() => 0}}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
or-pattern-alternatives-bind-different-name-sets at
example.tpz:3:10
Repaired program
Ссылкаfunction read(value: Option<int>) -> int {match (value) {case Some(_) | None() => 0}}
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.