Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0d991b

Browse files
Merge pull request argotorg#15533 from haoyang9804/calldata_doc
Add note about calldata arrays and structs initialization in docs
2 parents 323ad93 + eb7dc21 commit b0d991b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/types/reference-types.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ non-persistent area where function arguments are stored, and behaves mostly like
3737
data location can also be returned from functions, but it is not possible to
3838
allocate such types.
3939

40+
.. note::
41+
Arrays and structs with ``calldata`` location declared in a function body
42+
or as its return parameters must be assigned before being used or returned.
43+
There are certain cases in which non-trivial control flow is used and the compiler
44+
can't properly detect the initialization.
45+
A common workaround in such cases is to assign the affected variable to itself before
46+
the correct initialization takes place.
47+
4048
.. note::
4149
Prior to version 0.6.9 data location for reference-type arguments was limited to
4250
``calldata`` in external functions, ``memory`` in public functions and either

0 commit comments

Comments
 (0)