Diagnostic and cause
LinkType is not JSON encodable
- Family
- topaz
- Phase
- check
- Code
TPZ5533
Cause and conditions
json.stringify requires a JSON-encodable argument type. Passing a function value is rejected with TPZ5533; passing the function's integer result is accepted.
Related rule: Type is not JSON encodableResponse
Project the value into supported JSON data. Encode its data fields instead of passing behavior or opaque host values.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 873-882 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1217-1217 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1208-1221 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 415-432 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 498-517
Compiler phase: check.
Compiler explanation: JSON.stringify or a JSON encode path received a type outside the supported deterministic JSON shape.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
⟨value⟩is not JSON-encodable, sojson.cannot encode it Sourcestringify
json.stringify requires a JSON-encodable argument type. Passing a function value is rejected with TPZ5533; passing the function's integer result is accepted.
Type is not JSON encodable
json.stringify requires a JSON-encodable argument type. Passing a function value is rejected with TPZ5533; passing the function's integer result is accepted.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1208-1221 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 415-432 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 498-517
Response
LinkProject the value into supported JSON data. Encode its data fields instead of passing behavior or opaque host values.
Reproduction and verification
LinkRejected program
Linkimport std.jsonfunction compute() -> int { 1 }let encoded = json.stringify(compute)
No stdout.
Expected result
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1208-1221 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 415-432 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 498-517
Repaired program
Linkimport std.jsonfunction compute() -> int { 1 }let encoded = json.stringify(compute())
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1208-1221 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 415-432 - compiler/crates/topaz_self_frontend/topaz/checker/members_capabilities.tpz at
151141d7bb44· 498-517