본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    진단 TPZ5711

    A name bound by multiple alternatives of an or-pattern has inconsistent types.

    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.

    규칙diagnostics.tpz5711.p5.rule

    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

    링크
    example.tpzRejected program플레이그라운드 열기 →
    1. enum Item { Count(int), Text(string) }
    2. function read(item: Item) -> int {
    3. match (item) {
    4. case Count(value) | Text(value) => 0
    5. }
    6. }
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz check example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 check. 종료 코드가 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

    링크
    example.tpzRepaired program
    1. enum Item { Count(int), Text(int) }
    2. function read(item: Item) -> int {
    3. match (item) {
    4. case Count(value) | Text(value) => 0
    5. }
    6. }
    기대 출력종료 코드 0
    $ topaz check example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    검사가 프로그램을 받아들입니다. 종료 코드 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.

    메뉴

    다운로드 →