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

문서 검색

명세 6.0

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

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

    진단 TPZ5712

    A pattern binding that collides with a constructor produces TPZ5712 during checking.

    Diagnostic and cause

    링크

    Constructor name used as a pattern binding

    계열
    topaz
    단계
    check
    코드
    TPZ5712

    원인과 조건

    Write Name(patterns) in every pattern position. The payload list has the declared arity. A zero-payload constructor uses Name(), including None() and user enum variants such as Empty(). Nesting does not change this syntax. Parenthesized patterns with the wrong payload count retain the existing constructor-arity diagnostic.

    Write Name(arguments) in every value position at every arity. Constructor calls use None(), Empty(), or Some(value). Qualified enum construction uses the same argument list, as in Choice.Empty(). The grammar rejects a bare prelude None value. User enum constructor names are resolved and checked after parsing.

    A bare identifier in a pattern attempts to bind a new name. Its capitalization never selects a constructor role. A typed binding uses the same name rule.

    The constructor namespace includes prelude constructors, visible declarations and imports, and variants obtained from the known expected type after resolving aliases. A pattern binder that has the same identifier as one of those constructors is rejected with TPZ5712. This check applies at every nested pattern, to typed binders, and to constructors of another visible type. A value binding does not hide a constructor for this check. Choose a fresh name to capture the value or use _ to ignore it.

    None is already a reserved binding name. Without the constructor argument list it is rejected during parsing with TPZ2012. Other bare constructor names reach the namespace check. A removed bare enum pattern is never widened into a catch-all.

    대응

    Write the constructor argument list, including () at zero arity. To capture the matched value, choose a name absent from the constructor namespace.

    Topaz 6.0.0 specifies this diagnostic during checking.

    The target message is pattern binding Empty conflicts with a constructor.

    The pinned SELF source does not emit this diagnostic.

    Every constructor pattern uses an argument list. A bare identifier proposes a binding and cannot collide with a visible constructor. Typed bindings use the same rule. Value shadowing does not hide constructors. Report TPZ5712 at the binding name. Bare None retains its existing parse rejection. The constructor rule defines the constructor namespace and repair.

    규칙diagnostics.tpz5712.p5.rule

    Constructor name used as a pattern binding

    Every constructor pattern uses an argument list. A bare identifier proposes a binding and cannot collide with a visible constructor. Typed bindings use the same rule. Value shadowing does not hide constructors. Report TPZ5712 at the binding name. Bare None retains its existing parse rejection. The constructor rule defines the constructor namespace and repair.

    이유

    This applies the adopted constructor-parentheses.1 decision. The language chapter owns the rejection condition and source span.

    Response

    링크

    Write the constructor argument list, including () at zero arity. To capture the matched value, choose a name absent from the constructor namespace.

    Reproduction and verification

    링크

    Rejected program

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

    기대 결과

    거절 단계 check. 종료 코드가 0이 아닙니다.

    • TPZ5712 →

      pattern-constructor-binding-collision at example.tpz:4:14

    The matcher describes a Topaz 6.0 target message. Public Topaz 5.21.3 does not implement this diagnostic producer.

    Repaired program

    링크
    example.tpzRepaired program
    1. enum Choice { Empty, Filled(int), Pair(int, int) }
    2. function read(value: Choice) -> int {
    3. match (value) {
    4. case Empty() => 0
    5. case Filled(number) => number
    6. case Pair(left, right) => left + right
    7. }
    8. }
    9. function nested(value: Option<Choice>) -> int {
    10. match (value) {
    11. case None() => -1
    12. case Some(Empty()) => 0
    13. case Some(Filled(number)) => number
    14. case Some(Pair(left, right)) => left + right
    15. }
    16. }
    기대 출력종료 코드 0
    $ topaz check example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    검사가 프로그램을 받아들입니다. 종료 코드 0.

    The matcher describes a Topaz 6.0 target message. Public Topaz 5.21.3 does not implement this diagnostic producer.

    메뉴

    다운로드 →