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
patched_stdlib(parsejson): resolve CStringConv
warnings
#445
Conversation
@ee7 Can this be merged/updated? Those warnings are annoying :) |
6cc0244
to
43a237c
Compare
I'll try to finally finish nim-lang/Nim#19488 soon. I have a minor preference for merging this PR after that, so that we can either:
configlet/src/patched_stdlib/json.nim Lines 1 to 5 in 85e262c
|
I finally got around to finishing the upstream PR. So hopefully that'll be merged soon, and I'll finally merge this PR. Sorry for the wait. |
After the upgrade to Nim 1.6.0 in commit 761936b, a regular `nimble build` would produce these warnings: /foo/configlet/src/patched_stdlib/parsejson.nim(237, 37) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv] /foo/configlet/src/patched_stdlib/parsejson.nim(247, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv] I authored a commit [1] in the `nim-lang/Nim` repo that resolves the most visible CStringConv warnings, including these in parsejson, by making the cstring conversion explicit. Let's update configlet's copy of parsejson without waiting for a Nim version bump, so that we no longer see these CStringConv warnings while compiling configlet. As a reminder, we maintain our own copy of std/json and std/parsejson in the configlet repo so that we can forbid comments and trailing commas in JSON (see 15c8403 for details). As background, the Nim manual says that an implicit conversion to cstring will eventually not be allowed [2]: A Nim `string` is implicitly convertible to `cstring` for convenience. [...] Even though the conversion is implicit, it is not *safe*: The garbage collector does not consider a `cstring` to be a root and may collect the underlying memory. For this reason, the implicit conversion will be removed in future releases of the Nim compiler. Certain idioms like conversion of a `const` string to `cstring` are safe and will remain to be allowed. And from Nim 1.6.0, such a conversion triggers a warning [3]: A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning. This warning will become an error in future versions! Use an explicit conversion like `cstring(x)` in order to silence the warning. [1] nim-lang/Nim@e8657c710776 [2] https://github.com/nim-lang/Nim/blob/e8657c710776/doc/manual.md#cstring-type [3] https://github.com/nim-lang/Nim/blob/e8657c710776/changelogs/changelog_1_6_0.md#type-system
43a237c
to
d9c3efe
Compare
CStringConv
warningsCStringConv
warnings
I fixed these warnings in the repo for the Nim compiler, and rebased our patched |
After the upgrade to Nim 1.6.0 in commit 761936b, a regular
nimble build
would produce these warnings:I authored a commit in the
nim-lang/Nim
repo that resolves themost visible CStringConv warnings, including these in parsejson, by
making the cstring conversion explicit. Let's update configlet's copy of
parsejson without waiting for a Nim version bump, so that we no longer
see these CStringConv warnings while compiling configlet.
As a reminder, we maintain our own copy of std/json and std/parsejson in
the configlet repo so that we can forbid comments and trailing commas in
JSON (see 15c8403 for details).
As background, the Nim manual says that an implicit conversion to
cstring will eventually not be allowed:
And from Nim 1.6.0, such a conversion triggers a warning:
To-do:
parsejson.nim
file.