Diagnostic and cause
LinkType is not JSON decodable
- Family
- topaz
- Phase
- check
- Code
TPZ5534
Cause and conditions
json.parseAs requires an explicit JSON-decodable result type. Calling json.parseAs("1") without a type argument is rejected with TPZ5534; json. is accepted.
Response
Supply the target type after json.parseAs, such as json.. Choose a JSON-decodable type for the result.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 883-892 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1247-1247 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
17711dcdbc9b· 1227-1268
Compiler phase: check.
Compiler explanation: A typed JSON decode target is not a supported concrete Topaz data shape.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
⟨value⟩requires an explicit type argument, e.g.⟨value⟩<User>(.Source. . ) ⟨value⟩is not JSON-decodable, so⟨value⟩cannot decode into it Source
json.parseAs requires an explicit decodable result type. A call without type arguments is rejected with TPZ5534 even when its text contains a valid JSON integer.
Typed JSON decoding needs a type argument
json.parseAs requires an explicit JSON-decodable result type. Calling json.parseAs("1") without a type argument is rejected with TPZ5534; json. is accepted.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
17711dcdbc9b· 1227-1268
Response
LinkSupply the target type after json.parseAs, such as json.. Choose a JSON-decodable type for the result.
Reproduction and verification
LinkRejected program
Linkimport std.jsonlet decoded = json.parseAs("1")
No stdout.
Expected result
A bare call without type arguments can also report TPZ5020 for missing contextual type. The diagnostic assertion requires TPZ5534 and permits that accompanying diagnostic.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
17711dcdbc9b· 1227-1268
Repaired program
Linkimport std.jsonlet decoded = json.parseAs<int>("1")
Expected result
Expected result
Checking accepts the program. Exit code 0.
A bare call without type arguments can also report TPZ5020 for missing contextual type. The diagnostic assertion requires TPZ5534 and permits that accompanying diagnostic.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
17711dcdbc9b· 1227-1268