Diagnostic and cause
LinkAssertion failed
- Family
- topaz
- Phase
- run
- Code
TPZ4007
Cause and conditions
std.test.assertEq compares its two values. Equal integer arguments complete successfully; unequal integer arguments fail at runtime with TPZ4007 at the assertion call.
Related rule: Equality assertions require equal valuesResponse
Inspect both the program result and the assertion. Correct the program when its result is wrong; change the assertion when its intended expectation is wrong.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 562-570 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 60-60 - compiler/crates/topaz_value/src/lib.rs at
151141d7bb44· 167-167 - compiler/crates/topaz_value/src/value/builtins/test.rs at
151141d7bb44· 3-35 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 39-60
Compiler phase: runtime.
Compiler explanation: A std.test assertion evaluated to failure.
Message templates are Pending. The explanation above is not an observed CLI message.
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ4007]: assertEq failed: actual
1!= expected2
std.test.assertEq compares its two values. Equal integer arguments complete successfully; unequal integer arguments fail at runtime with TPZ4007 at the assertion call.
Equality assertions require equal values
std.test.assertEq compares its two values. Equal integer arguments complete successfully; unequal integer arguments fail at runtime with TPZ4007 at the assertion call.
Source evidence
- compiler/crates/topaz_value/src/value/builtins/test.rs at
151141d7bb44· 3-35 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 39-60
Response
LinkInspect both the program result and the assertion. Correct the program when its result is wrong; change the assertion when its intended expectation is wrong.
Reproduction and verification
LinkRejected program
Linkimport std.test as TestTest.assertEq(1, 2)
No stdout.
Expected result
Run the paired runtime product assertions with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs. The shared example observer currently evaluates check diagnostics.
Source evidence
- compiler/crates/topaz_value/src/value/builtins/test.rs at
151141d7bb44· 3-35 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 39-60
Repaired program
Linkimport std.test as TestTest.assertEq(1, 1)
No stdout.
Expected result
Expected result
Execution completes. Exit code 0.
Run the paired runtime product assertions with TOPAZ_BIN set using node docs/topaz-reference/templates/diagnostics-p5-runtime.product.mjs. The shared example observer currently evaluates check diagnostics.
Source evidence
- compiler/crates/topaz_value/src/value/builtins/test.rs at
151141d7bb44· 3-35 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 39-60