Diagnostic and cause
LinkComprehension body type mismatch
- Family
- topaz
- Phase
- check
- Code
TPZ5610
Cause and conditions
A comprehension body must satisfy the element type required by its collection context. An Array<int> comprehension whose body produces string must be rejected with the registered TPZ5610 diagnostic.
Response
Make the body produce the expected element type, or change the collection annotation to match the intended data.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 906-915 - compiler/crates/topaz_diag/src/explain.rs at
17711dcdbc9b· 906-915 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 1768-1776 - compiler/crates/topaz_self_frontend/topaz/checker/statements.tpz at
17711dcdbc9b· 460-475 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
17711dcdbc9b· 1660-1683
Compiler phase: check.
Compiler explanation: A comprehension body does not match the element type required by its expected context.
Message templates are Pending. The explanation above is not an observed CLI message.
A comprehension body must satisfy the element type required by its collection context. An Array<int> comprehension whose body produces string must be rejected with the registered TPZ5610 diagnostic.
Comprehension body and expected element type
A comprehension body must satisfy the element type required by its collection context. An Array<int> comprehension whose body produces string must be rejected with the registered TPZ5610 diagnostic.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
17711dcdbc9b· 906-915 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 1768-1776 - compiler/crates/topaz_self_frontend/topaz/checker/statements.tpz at
17711dcdbc9b· 460-475 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
17711dcdbc9b· 1660-1683
Response
LinkMake the body produce the expected element type, or change the collection annotation to match the intended data.
Reproduction and verification
LinkRejected program
Linklet values: Array<int> = [for value in ([1]) => "text"]
No stdout.
Expected result
Expected result
Rejection during check. Nonzero exit.
TPZ5610comprehension-body-type-mismatch
The required primary-location contract is Pending.
The source establishes a TPZ5001 collection mismatch for this input. The product assertion retains the intended TPZ5610 identity. Its dedicated message and primary location remain undetermined; the cause matcher recognizes the actual source-backed mismatch text.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
17711dcdbc9b· 906-915 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 1768-1776 - compiler/crates/topaz_self_frontend/topaz/checker/statements.tpz at
17711dcdbc9b· 460-475 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
17711dcdbc9b· 1660-1683
Repaired program
Linklet values: Array<int> = [for value in ([1]) => value]
Expected result
Expected result
Checking accepts the program. Exit code 0.
The source establishes a TPZ5001 collection mismatch for this input. The product assertion retains the intended TPZ5610 identity. Its dedicated message and primary location remain undetermined; the cause matcher recognizes the actual source-backed mismatch text.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
17711dcdbc9b· 906-915 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 1768-1776 - compiler/crates/topaz_self_frontend/topaz/checker/statements.tpz at
17711dcdbc9b· 460-475 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
17711dcdbc9b· 1660-1683