Skip to content

Commit ac13573

Browse files
committed
refine the doc about calldata
1 parent 6ef580c commit ac13573

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/contracts/visibility-and-getters.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ to select individual struct members or provide a key for the mapping:
221221
a = data[arg1][arg2][arg3].a;
222222
b = data[arg1][arg2][arg3].b;
223223
e = data[arg1][arg2][arg3].e;
224-
}
224+
}

docs/types/reference-types.rst

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

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

0 commit comments

Comments
 (0)