Skip to content

Commit 0381de5

Browse files
committed
Update docs.
1 parent 93dd8ad commit 0381de5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

docs/assembly.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ model as follows:
297297

298298
.. code-block:: solidity
299299
300-
/// @solidity memory-safe-assembly
301-
assembly {
300+
assembly ("memory-safe") {
302301
...
303302
}
304303
@@ -327,8 +326,7 @@ But the following is:
327326

328327
.. code-block:: solidity
329328
330-
/// @solidity memory-safe-assembly
331-
assembly {
329+
assembly ("memory-safe") {
332330
let p := mload(0x40)
333331
returndatacopy(p, 0, returndatasize())
334332
revert(p, returndatasize())
@@ -341,8 +339,7 @@ If the memory operations use a length of zero, it is also fine to just use any o
341339

342340
.. code-block:: solidity
343341
344-
/// @solidity memory-safe-assembly
345-
assembly {
342+
assembly ("memory-safe") {
346343
revert(0, 0)
347344
}
348345
@@ -364,3 +361,16 @@ in memory is automatically considered memory-safe and does not need to be annota
364361
It is your responsibility to make sure that the assembly actually satisfies the memory model. If you annotate
365362
an assembly block as memory-safe, but violate one of the memory assumptions, this **will** lead to incorrect and
366363
undefined behaviour that cannot easily be discovered by testing.
364+
365+
In case you are developing a library that is meant to be compatible across multiple versions
366+
of solidity, you can use a special comment to annotate an assembly block as memory-safe:
367+
368+
.. code-block:: solidity
369+
370+
/// @solidity memory-safe-assembly
371+
assembly {
372+
...
373+
}
374+
375+
Note that we will disallow the annotation via comment in a future breaking release, so if you are not concerned with
376+
backwards-compatibility with older compiler versions, prefer using the dialect string.

0 commit comments

Comments
 (0)