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.
관련 규칙 · Type is not JSON encodable →대응
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, 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.
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
링크import std.jsonfunction compute() -> int { 1 }let encoded = json.stringify(compute)
표준 출력 없음.기대 결과
Repaired program
링크import std.jsonfunction compute() -> int { 1 }let encoded = json.stringify(compute())
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.