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

문서 검색

명세 6.0

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

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

    진단 TPZ5523

    Explains a repeated protocol bound on one function type parameter and its correction.

    Identity and cause

    링크

    TPZ5523

    계열
    topaz
    단계
    check
    코드
    TPZ5523

    원인과 조건

    Each type parameter names a resolved protocol identity once. Repeating that identity produces TPZ5523, including through namespace qualification or aliases. A distinct protocol declaration remains a different requirement even when another module gives it the same name.

    대응

    A function declaration names the same protocol more than once in the bounds of one type parameter. The checker compares the protocol name together with the type-parameter index. Repetition on one parameter is distinct from using that protocol on two different parameters. It attaches TPZ5523 to the repeated bound.

    Rejected example

    링크

    Repeated-bound example

    링크
    example.tpzRepeated-bound example플레이그라운드 열기 →
    1. function duplicate<T: Show + Show>(value: T) -> T {
    2. value
    3. }
    기대 출력0이 아닌 종료 코드
    $ topaz check example.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    TPZ5523 points to the second Show at example.tpz:1:30. Each later occurrence for the same type parameter is diagnosed. Checking continues, so other applicable diagnostics may also appear. Remove the repeated bound to correct this program. The earlier receipt predates the location assertion; CI must execute this revision.

    Observed: The authored exit and diagnostic-cause assertions passed. The primary-location assertion and additional-diagnostics policy remain pending. Recorded with Topaz 5.21.3 in run 42147883818 at 2026-11-06T02:04:56.5052224Z. Document source: 1d6f9265d918.

    Fix

    링크

    Keep one occurrence of each required protocol. If additional, distinct protocols are required, retain those bounds. This correction removes repetition; the repaired example checks the complete program.

    Repeated bound removed

    링크
    example.tpzRepeated bound removed
    1. function duplicate<T: Show>(value: T) -> T {
    2. value
    3. }
    기록된 출력종료 코드 0
    example.tpz: types-ok (1 module)
    example.tpz: resolve-ok (1 module)
    
    $ topaz check example.tpz · 기록에 사용한 토파즈 5.21.3
    기대 결과

    기대 결과

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

    관측한 단언 · 통과 · 5.21.3

    종료 코드 0.

    관측한 표준 출력
    1. example.tpz: types-ok (1 module)
    2. example.tpz: resolve-ok (1 module)

    표준 오류 출력 없음.

    • 통과 · expected 0; observed 0

    Acceptance of this corrected complete program is a separate check.

    Observed: The authored assertions passed. Recorded with Topaz 5.21.3 in run 42147883818 at 2026-11-06T02:04:56.5498911Z. Document source: 1d6f9265d918.

    Verification

    링크

    The examples reuse the exact source, independent expectations, and product observations shown in Functions and generics. The required primary location and additional-diagnostic policy remain Pending.

    Related rules

    링크

    Functions and generics →

    Exported functions also have restrictions on exposing module-local protocols. Those are reported separately as TPZ5524 and are not repaired merely by removing duplicates.

    메뉴

    다운로드 →