Prerequisite
СсылкаUse Topaz 5.21.3 with the SELF compiler and language mode 5.21. This walkthrough starts with a repeated protocol bound and ends with a checked assertion.
1. Read the diagnostic code
СсылкаThe rejected declaration repeats Show for one type parameter. Check it and use TPZ5523 to find the diagnostic explanation. Its recorded output comes from the same example used by the Language reference.
Repeated-bound example
Ссылкаfunction duplicate<T: Show + Show>(value: T) -> T {value}
Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
repeated-protocol-bound at
example.tpz:1:30
TPZ5523 points to the second Show at example.. 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-. Document source: 1d6f9265d918.
2. Ask for the explanation
СсылкаRun topaz explain TPZ5523. Expected result: the command explains the repeated protocol bound and recommends removing the repeated name. This command's execution remains Pending in this walkthrough.
3. Repair the declaration and check
СсылкаSave the complete source as diagnose-. The declaration now contains one Show bound. Sample derives Show, so the call uses a record that provides the requested protocol. The assertion compares the returned record's value with 3. See Type parameters and bounds for the rules.
Check the repaired program
Ссылкаimport std.testrecord Sample derives Show {value: int,}function duplicate<T: Show>(value: T) -> T {value}let result = duplicate(Sample { value: 3 })test.assertEq(result.value, 3)
diagnose-and-test.tpz: types-ok (2 modules)
diagnose-and-test.tpz: resolve-ok (2 modules)
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.
Наблюдаемые утверждения · Пройдено · 5.21.3
Код завершения 0.
diagnose-and-test.tpz: types-ok (2 modules)diagnose-and-test.tpz: resolve-ok (2 modules)
Нет вывода ошибок.
- Пройдено · expected 0; observed 0
4. Execute the assertion
СсылкаRun the assertion with topaz test
Ссылкаimport std.testrecord Sample derives Show {value: int,}function duplicate<T: Show>(value: T) -> T {value}let result = duplicate(Sample { value: 3 })test.assertEq(result.value, 3)
diagnose-and-test.tpz: test-ok
Ожидаемый результат
Ожидаемый результат
Выполнение завершается. Код завершения 0.
diagnose-and-test.tpz: test-ok
Наблюдаемые утверждения · Пройдено · 5.21.3
Код завершения 0.
diagnose-and-test.tpz: test-ok
Нет вывода ошибок.
- Пройдено · expected 0; observed 0
- Пройдено · stdout matches the authored expectation
- Пройдено · stderr matches the authored expectation
Expected result: the command exits successfully and prints diagnose-. test. checks the returned value while the program runs. If the assertion fails, inspect the function result and the expected value, then rerun the test.
Verification record
СсылкаPublic Topaz 5.21.3 passed the repaired check and test expectations in Docs run 42224592687, attempt 2. The recorded results were compared with this page's current product assertions using unchanged fixture files, invocations and expectations. The shared TPZ5523 rejection specifies its source location and additional-diagnostic policy. Its current example revision awaits a product run. The test output and equality-assertion contracts are listed below.
See test, explain and std.test.assertEq for their current reference entries.