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

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

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

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

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

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

    JSON.stringify or a JSON encode path received a type outside the supported deterministic JSON shape.

    Diagnostic and cause

    Ссылка

    Type is not JSON encodable

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

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

    json.stringify requires a JSON-encodable argument type. Passing a function value is rejected with TPZ5533; passing the function's integer result is accepted.

    Действия

    Project the value into supported JSON data. Encode its data fields instead of passing behavior or opaque host values.

    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, so json.stringify cannot encode it Source

    json.stringify requires a JSON-encodable argument type. Passing a function value is rejected with TPZ5533; passing the function's integer result is accepted.

    Правилоdiagnostics.tpz5533.p5.rule

    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.

    Response

    Ссылка

    Project the value into supported JSON data. Encode its data fields instead of passing behavior or opaque host values.

    Reproduction and verification

    Ссылка

    Rejected program

    Ссылка
    example.tpzRejected programОткрыть песочницу →
    1. import std.json
    2. function compute() -> int { 1 }
    3. let encoded = json.stringify(compute)
    Ожидаемый выводНенулевой код завершения
    Нет стандартного вывода.
    $ topaz check example.tpz · Целевой продукт 5.21.3
    Ожидаемый результат

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

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

    Repaired program

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

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

    Проверка принимает программу. Код завершения 0.

    Меню

    Загрузка →