Skip to content

Commit

Permalink
Merge pull request #15533 from haoyang9804/calldata_doc
Browse files Browse the repository at this point in the history
Add note about calldata arrays and structs initialization in docs
  • Loading branch information
matheusaaguiar authored Nov 11, 2024
2 parents 323ad93 + eb7dc21 commit b0d991b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/types/reference-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ non-persistent area where function arguments are stored, and behaves mostly like
data location can also be returned from functions, but it is not possible to
allocate such types.

.. note::
Arrays and structs with ``calldata`` location declared in a function body
or as its return parameters must be assigned before being used or returned.
There are certain cases in which non-trivial control flow is used and the compiler
can't properly detect the initialization.
A common workaround in such cases is to assign the affected variable to itself before
the correct initialization takes place.

.. note::
Prior to version 0.6.9 data location for reference-type arguments was limited to
``calldata`` in external functions, ``memory`` in public functions and either
Expand Down

1 comment on commit b0d991b

@ibrahimkhled
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.