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}}
표준 출력 없음.기대 결과
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.