Diagnostic and cause
링크Redeclaration
- 계열
- topaz
- 단계
- check
- 코드
TPZ5008
원인과 조건
A protocol implementation must not define the same method twice. A duplicate method is rejected with TPZ5008 at the later method name.
관련 규칙 · A protocol implementation defines each method once →대응
Rename or remove the later duplicate. Use a nested scope when a separate local binding is intended.
Compiler phase: check/runtime.
Compiler explanation: A scope declares the same value name more than once.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- duplicate concurrent arm
⟨value⟩Source - field
⟨value⟩is given twice in⟨value⟩Source - record field
⟨value⟩is declared twice in⟨value⟩Source - method
⟨value⟩is already declared in protocol⟨value⟩Source ⟨value⟩is a builtin protocol and cannot be redeclared Source- protocol
⟨value⟩is already declared Source - nominal record pattern field
⟨value⟩is specified more than once Source ⟨value⟩is already declared in this scope Source- method
⟨value⟩is implemented twice inimpl ⟨value⟩<⟨value⟩>Source - method
⟨value⟩is already defined for⟨value⟩Source ⟨value⟩is already declared in this scope Source⟨value⟩is already declared in this scope Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5008]: method
showis implemented twice inimpl Show<Item>
A protocol implementation must not define the same method twice. A duplicate method is rejected with TPZ5008 at the later method name.
A protocol implementation defines each method once
A protocol implementation must not define the same method twice. A duplicate method is rejected with TPZ5008 at the later method name.
Response
링크Rename or remove the later duplicate. Use a nested scope when a separate local binding is intended.
Reproduction and verification
링크Rejected program
링크record Item { value: int }impl Show<Item> {function show(value: Item) -> string { "first" }function show(value: Item) -> string { "second" }}
표준 출력 없음.기대 결과
Repaired program
링크record Item { value: int }impl Show<Item> {function show(value: Item) -> string { "first" }}
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.