From eb7dc2169b58a59a0d57ea6ca61d2fa0b548c324 Mon Sep 17 00:00:00 2001 From: haoyang9804 Date: Fri, 18 Oct 2024 22:20:54 +0100 Subject: [PATCH] refine the doc about calldata --- docs/types/reference-types.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index 4a053d51beea..23119484d103 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -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