@@ -30,7 +30,7 @@ The design of Yul tries to achieve several goals:
3030In order to achieve the first and second goal, Yul provides high-level constructs
3131like ``for `` loops, ``if `` and ``switch `` statements and function calls. These should
3232be sufficient for adequately representing the control flow for assembly programs.
33- Therefore, no explicit statements for ``SWAP ``, ``DUP ``, ``JUMP `` and ``JUMPI ``
33+ Therefore, no explicit statements for ``SWAP ``, ``DUP ``, ``JUMPDEST ``, `` JUMP `` and ``JUMPI ``
3434are provided, because the first two obfuscate the data flow
3535and the last two obfuscate control flow. Furthermore, functional statements of
3636the form ``mul(add(x, y), 7) `` are preferred over pure opcode statements like
@@ -180,7 +180,11 @@ appropriate ``PUSHi`` instruction. In the following example,
180180``3 `` and ``2 `` are added resulting in 5 and then the
181181bitwise ``and `` with the string "abc" is computed.
182182The final value is assigned to a local variable called ``x ``.
183+
183184Strings are stored left-aligned and cannot be longer than 32 bytes.
185+ The limit does not apply to string literals passed to builtin functions that require
186+ literal arguments (e.g. ``setimmutable `` or ``loadimmutable ``). Those strings never end up in the
187+ generated bytecode.
184188
185189.. code-block :: yul
186190
@@ -284,6 +288,8 @@ variables at the same time. For this, the number and types of the
284288values have to match.
285289If you want to assign the values returned from a function that has
286290multiple return parameters, you have to provide multiple variables.
291+ The same variable may not occur multiple times on the left-hand side of
292+ an assignment, e.g. ``x, x := f() `` is invalid.
287293
288294.. code-block :: yul
289295
@@ -502,6 +508,8 @@ In variable declarations and assignments, the right-hand-side expression
502508variables on the left-hand-side.
503509This is the only situation where an expression evaluating
504510to more than one value is allowed.
511+ The same variable name cannot occur more than once in the left-hand-side of
512+ an assignment or variable declaration.
505513
506514Expressions that are also statements (i.e. at the block level) have to
507515evaluate to zero values.
@@ -904,7 +912,7 @@ In some internal dialects, there are additional functions:
904912datasize, dataoffset, datacopy
905913^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
906914
907- The functions ``datasize(x) ``, ``dataoffset(x) `` and ``datacopy(t, f, l) ``,
915+ The functions ``datasize(x) ``, ``dataoffset(x) `` and ``datacopy(t, f, l) ``
908916are used to access other parts of a Yul object.
909917
910918``datasize `` and ``dataoffset `` can only take string literals (the names of other objects)
@@ -916,13 +924,37 @@ setimmutable, loadimmutable
916924^^^^^^^^^^^^^^^^^^^^^^^^^^^
917925
918926The functions ``setimmutable("name", value) `` and ``loadimmutable("name") `` are
919- used for the immutable mechanism in Solidity and do not nicely map to pur Yul.
927+ used for the immutable mechanism in Solidity and do not nicely map to pure Yul.
920928The function ``setimmutable `` assumes that the runtime code of a contract
921- is currently copied to memory at offsot zero. The call to ``setimmutable("name", value) ``
929+ is currently copied to memory at offset zero. The call to ``setimmutable("name", value) ``
922930will store ``value `` at all points in memory that contain a call to
923931``loadimmutable("name") ``.
924932
925933
934+ linkersymbol
935+ ^^^^^^^^^^^^
936+
937+ The function ``linkersymbol("fq_library_name") `` is a placeholder for an address literal to be
938+ substituted by the linker. Its first and only argument must be a string literal and represents the
939+ fully qualified library name used with the ``--libraries `` option.
940+
941+ For example this code
942+
943+ .. code-block :: yul
944+
945+ let a := linkersymbol("file.sol:Math")
946+
947+ is equivalent to
948+
949+ .. code-block :: yul
950+
951+ let a := 0x1234567890123456789012345678901234567890
952+
953+ when the linker is invoked with ``--libraries "file.sol:Math:0x1234567890123456789012345678901234567890 ``
954+ option.
955+
956+ See :ref: `Using the Commandline Compiler <commandline-compiler >` for details about the Solidity linker.
957+
926958
927959.. _yul-object :
928960
0 commit comments