Nim/lib/impure
ee7 e8657c7107
make implicit cstring conversions explicit (#19488)
The Nim manual says that an implicit conversion to cstring will
eventually not be allowed [1]:

    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 [2]:

    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.

However, some files in this repo produced such a warning. For example,
before this commit, compiling `parsejson.nim` would produce:

    /foo/Nim/lib/pure/parsejson.nim(221, 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/Nim/lib/pure/parsejson.nim(231, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]

This commit resolves the most visible `CStringConv` warnings, making the
cstring conversions explicit.

[1] d2318d9ccf/doc/manual.md (cstring-type)
[2] d2318d9ccf/changelogs/changelog_1_6_0.md (type-system)
2022-08-19 15:40:53 -04:00
..
nre fixes #13654 2020-03-16 23:00:43 +01:00
db_mysql.nim make implicit cstring conversions explicit (#19488) 2022-08-19 15:40:53 -04:00
db_odbc.nim make implicit cstring conversions explicit (#19488) 2022-08-19 15:40:53 -04:00
db_postgres.nim make implicit cstring conversions explicit (#19488) 2022-08-19 15:40:53 -04:00
db_sqlite.nim make implicit cstring conversions explicit (#19488) 2022-08-19 15:40:53 -04:00
nre.nim fix typo in nre.nim (#19915) 2022-06-21 09:53:46 +08:00
rdstdin.nim fix not flushing stdout in MSYS (#19590) 2022-03-07 17:21:42 +08:00
re.nim fix bug #14468 zero-width split (#19248) 2021-12-13 07:29:22 +01:00