Skip to content

Commit 6c4cfd8

Browse files
authored
Merge pull request #13293 from krakxn/develop
Grammatical fixes in `assembly.rst`
2 parents 800088e + b828da2 commit 6c4cfd8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

docs/assembly.rst

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Inline Assembly
88

99

1010
You can interleave Solidity statements with inline assembly in a language close
11-
to the one of the Ethereum virtual machine. This gives you more fine-grained control,
11+
to the one of the Ethereum Virtual Machine. This gives you more fine-grained control,
1212
which is especially useful when you are enhancing the language by writing libraries.
1313

1414
The language used for inline assembly in Solidity is called :ref:`Yul <yul>`
@@ -126,15 +126,15 @@ You can access Solidity variables and other identifiers by using their name.
126126
Local variables of value type are directly usable in inline assembly.
127127
They can both be read and assigned to.
128128

129-
Local variables that refer to memory evaluate to the address of the variable in memory not the value itself.
129+
Local variables that refer to memory evaluate to the address of the variable in memory, not the value itself.
130130
Such variables can also be assigned to, but note that an assignment will only change the pointer and not the data
131131
and that it is your responsibility to respect Solidity's memory management.
132132
See :ref:`Conventions in Solidity <conventions-in-solidity>`.
133133

134134
Similarly, local variables that refer to statically-sized calldata arrays or calldata structs
135135
evaluate to the address of the variable in calldata, not the value itself.
136-
The variable can also be assigned a new offset, but note that no validation to ensure that
137-
the variable will not point beyond ``calldatasize()`` is performed.
136+
The variable can also be assigned a new offset, but note that no validation is performed to ensure that
137+
the variable will not point beyond ``calldatasize()``.
138138

139139
For external function pointers the address and the function selector can be
140140
accessed using ``x.address`` and ``x.selector``.
@@ -205,7 +205,7 @@ Local Solidity variables are available for assignments, for example:
205205
``assembly { signextend(<num_bytes_of_x_minus_one>, x) }``
206206

207207

208-
Since Solidity 0.6.0 the name of a inline assembly variable may not
208+
Since Solidity 0.6.0, the name of a inline assembly variable may not
209209
shadow any declaration visible in the scope of the inline assembly block
210210
(including variable, contract and function declarations).
211211

@@ -253,7 +253,7 @@ starting from where this pointer points at and update it.
253253
There is no guarantee that the memory has not been used before and thus
254254
you cannot assume that its contents are zero bytes.
255255
There is no built-in mechanism to release or free allocated memory.
256-
Here is an assembly snippet you can use for allocating memory that follows the process outlined above
256+
Here is an assembly snippet you can use for allocating memory that follows the process outlined above:
257257

258258
.. code-block:: yul
259259
@@ -276,7 +276,7 @@ first slot of the array and followed by the array elements.
276276

277277
.. warning::
278278
Statically-sized memory arrays do not have a length field, but it might be added later
279-
to allow better convertibility between statically- and dynamically-sized arrays, so
279+
to allow better convertibility between statically and dynamically-sized arrays; so,
280280
do not rely on this.
281281

282282
Memory Safety
@@ -290,7 +290,7 @@ perform additional memory optimizations, if it can rely on certain assumptions a
290290
While we recommend to always respect Solidity's memory model, inline assembly allows you to use memory
291291
in an incompatible way. Therefore, moving stack variables to memory and additional memory optimizations are,
292292
by default, disabled in the presence of any inline assembly block that contains a memory operation or assigns
293-
to solidity variables in memory.
293+
to Solidity variables in memory.
294294

295295
However, you can specifically annotate an assembly block to indicate that it in fact respects Solidity's memory
296296
model as follows:
@@ -346,7 +346,7 @@ If the memory operations use a length of zero, it is also fine to just use any o
346346
}
347347
348348
Note that not only memory operations in inline assembly itself can be memory-unsafe, but also assignments to
349-
solidity variables of reference type in memory. For example the following is not memory-safe:
349+
Solidity variables of reference type in memory. For example the following is not memory-safe:
350350

351351
.. code-block:: solidity
352352
@@ -356,17 +356,16 @@ solidity variables of reference type in memory. For example the following is not
356356
}
357357
x[0x20] = 0x42;
358358
359-
Inline assembly that neither involves any operations that access memory nor assigns to any solidity variables
359+
Inline assembly that neither involves any operations that access memory nor assigns to any Solidity variables
360360
in memory is automatically considered memory-safe and does not need to be annotated.
361361

362362
.. warning::
363363
It is your responsibility to make sure that the assembly actually satisfies the memory model. If you annotate
364364
an assembly block as memory-safe, but violate one of the memory assumptions, this **will** lead to incorrect and
365365
undefined behaviour that cannot easily be discovered by testing.
366366

367-
The annotation was introduced in version 0.8.13 and is not supported by older compilers.
368367
In case you are developing a library that is meant to be compatible across multiple versions
369-
of Solidity, you can use a special Natspec comment that has the same effect but is ignored in older versions:
368+
of Solidity, you can use a special comment to annotate an assembly block as memory-safe:
370369

371370
.. code-block:: solidity
372371
@@ -375,5 +374,5 @@ of Solidity, you can use a special Natspec comment that has the same effect but
375374
...
376375
}
377376
378-
Note that we will disallow the annotation via comment in a future breaking release, so if you are not concerned with
377+
Note that we will disallow the annotation via comment in a future breaking release; so, if you are not concerned with
379378
backwards-compatibility with older compiler versions, prefer using the dialect string.

0 commit comments

Comments
 (0)