Prerequisite
LinkUse 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
LinkThe 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
Linkfunction duplicate<T: Show + Show>(value: T) -> T {value}
Expected result
Expected result
Rejection during check. Nonzero exit.
TPZ5523repeated-protocol-bound atexample.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.
Source evidence
- Functions and generics manuscript at
d61f9fd0efb0· 5.3D - checkFunctionDeclarationInner bound iteration at
151141d7bb44· 177-191
2. Ask for the explanation
LinkRun 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
LinkSave 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
Linkimport 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)
Expected result
Expected result
Checking accepts the program. Exit code 0.
Observed assertions · passed · 5.21.3
Exit code 0.
diagnose-and-test.tpz: types-ok (2 modules)diagnose-and-test.tpz: resolve-ok (2 modules)
No stderr.
- Passed · expected 0; observed 0
Source evidence
- checkFunctionDeclarationInner at
b48527d0a174· 177-191 - typeConforms and checkFunctionBounds at
b48527d0a174· 2244-2335 - TPZ5523 explanation and correction at
b48527d0a174· 843-852 - Topaz 5.21 module selection at
b48527d0a174· 50-74 - STD_TEST_521 at
b48527d0a174· 438-448
4. Execute the assertion
LinkRun the assertion with topaz test
Linkimport 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
Expected result
Expected result
Execution completes. Exit code 0.
diagnose-and-test.tpz: test-ok
Observed assertions · passed · 5.21.3
Exit code 0.
diagnose-and-test.tpz: test-ok
No stderr.
- Passed · expected 0; observed 0
- Passed · stdout matches the authored expectation
- Passed · stderr matches the authored expectation
Source evidence
- typeConforms and checkFunctionBounds at
b48527d0a174· 2244-2335 - Topaz 5.21 module selection at
b48527d0a174· 50-74 - STD_TEST_521 at
b48527d0a174· 438-448 - test_selected_entry SELF route at
b48527d0a174· 125-134 - SELF test completion status at
b48527d0a174· 92-100
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
LinkPublic 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.