Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ5534: Type is not JSON decodable

    A typed JSON decode target is not a supported concrete Topaz data shape.

    Diagnostic and cause

    Link

    Type 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.parseAs<int>("1") is accepted.

    Response

    Supply the target type after json.parseAs, such as json.parseAs<int>("1"). Choose a JSON-decodable type for the result.

    Source evidence

    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.

    Rulediagnostics.tpz5534.p5.rule

    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.parseAs<int>("1") is accepted.

    Source evidence

    Response

    Link

    Supply the target type after json.parseAs, such as json.parseAs<int>("1"). Choose a JSON-decodable type for the result.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. import std.json
    2. let decoded = json.parseAs("1")
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5534 diagnostic-tpz5534 at example.tpz:2:15

    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

    Repaired program

    Link
    example.tpzRepaired program
    1. import std.json
    2. let decoded = json.parseAs<int>("1")
    Expected outputexit 0
    $ topaz check example.tpz · target product 5.21.3
    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

    Menu

    Download