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

follow #8463 #14157 and document cstring literals modification is not allowed #15878

Merged
merged 14 commits into from
Nov 12, 2020
14 changes: 14 additions & 0 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,20 @@ string from a cstring:
var cstr: cstring = str
var newstr: string = $cstr

``cstring`` literals shouldn't be modified.

.. code-block:: nim
var x = cstring"literals"
x[1] = 'A' # This is wrong!!!

If the ``cstring`` originates from a regular memory (not read-only memory),
it can be modified:

.. code-block:: nim
var x = "123456"
var s: cstring = x
s[0] = 'u' # This is ok

Structured types
----------------
A variable of a structured type can hold multiple values at the same
Expand Down