Diagnostic and cause
СсылкаOr-pattern binding types disagree
- Семейство
- topaz
- Этап
- check
- Код
TPZ5711
Причина и условия
Binding the same name to disjoint payload types across or-pattern alternatives is rejected with TPZ5711. In this program, int and string cannot give value a compatible binding type.
Действия
Use compatible payload types for a shared binding, or split the alternatives into separate arms. The repaired enum supplies int from both alternatives.
Compiler phase: check.
Compiler explanation: A name bound by multiple alternatives of an or-pattern has inconsistent types.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- binding
⟨value⟩has type⟨value⟩in one or-pattern alternative and⟨value⟩in another Source
Binding the same name to disjoint payload types across or-pattern alternatives is rejected with TPZ5711. In this program, int and string cannot give value a compatible binding type.
Or-pattern binding types must be compatible
Binding the same name to disjoint payload types across or-pattern alternatives is rejected with TPZ5711. In this program, int and string cannot give value a compatible binding type.
Response
СсылкаUse compatible payload types for a shared binding, or split the alternatives into separate arms. The repaired enum supplies int from both alternatives.
Reproduction and verification
СсылкаRejected program
Ссылкаenum Item { Count(int), Text(string) }function read(item: Item) -> int {match (item) {case Count(value) | Text(value) => 0}}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5711 at
example.tpz:4:10
The checker tests whether the collected types are disconnected under type overlap. This example establishes the disjoint int/string case; it does not require all alternative type spellings to be identical.
Repaired program
Ссылкаenum Item { Count(int), Text(int) }function read(item: Item) -> int {match (item) {case Count(value) | Text(value) => 0}}
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.
The checker tests whether the collected types are disconnected under type overlap. This example establishes the disjoint int/string case; it does not require all alternative type spellings to be identical.