Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #11988, don't make JSON parse natively in compile time #11994

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/pure/json.nim
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ when defined(nimJsonGet):
else:
{.pragma: deprecatedGet.}

const nativeJs = defined(js) and not nimvm

type
JsonNodeKind* = enum ## possible JSON node types
JNull,
Expand Down Expand Up @@ -840,7 +842,7 @@ proc parseJson(p: var JsonParser): JsonNode =
of tkError, tkCurlyRi, tkBracketRi, tkColon, tkComma, tkEof:
raiseParseErr(p, "{")

when not defined(js):
when not nativeJs:
proc parseJson*(s: Stream, filename: string = ""): JsonNode =
## Parses from a stream `s` into a `JsonNode`. `filename` is only needed
## for nice error messages.
Expand Down Expand Up @@ -1769,3 +1771,8 @@ when isMainModule:
)

doAssert(obj == to(%obj, type(obj)))

# bug #11988
when defined(js):
const jsConstantNode = parseJson("12")
doAssert(jsConstantNode.num == 12)