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" }}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5008 at
example.tpz:4:12
Repaired program
Ссылкаrecord Item { value: int }impl Show<Item> {function show(value: Item) -> string { "first" }}
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.