Перейти к содержимому
Топаз6.0 · До релиза
Загрузка →

Поиск в документации

Спецификация 6.0

Выберите результат стрелками и нажмите Enter, чтобы открыть его.

Введите имя API, номер диагностики, правило или тему проекта.

    Диагностика TPZ5534

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

    Diagnostic and cause

    Ссылка

    Type is not JSON decodable

    Семейство
    topaz
    Этап
    check
    Код
    TPZ5534

    Причина и условия

    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.

    Действия

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

    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.

    Правилоdiagnostics.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.

    Response

    Ссылка

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

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. import std.json
    2. let decoded = json.parseAs("1")
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Этап отклонения check. Ненулевой код завершения.

    A bare call without type arguments can also report TPZ5020 for missing contextual type. The diagnostic assertion requires TPZ5534 and permits that accompanying diagnostic.

    Repaired program

    Ссылка
    example.tpzRepaired program
    1. import std.json
    2. let decoded = json.parseAs<int>("1")
    Ожидаемый выводКод завершения 0
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

    Ожидаемый результат

    Проверка принимает программу. Код завершения 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.

    Меню

    Загрузка →