From ec4ccf81830b39522fe9074b61fc67bf687954f7 Mon Sep 17 00:00:00 2001 From: minami Date: Thu, 4 Aug 2022 15:51:22 +0900 Subject: [PATCH] Improve docs of possible function inputs and outputs --- docs/contracts/functions.rst | 26 ++++++++++---------------- docs/layout-of-source-files.rst | 21 ++++++++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index c7b7cc56b..f14e4b8a5 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -72,16 +72,6 @@ with two integers, you would use something like the following: Function parameters can be used as any other local variable and they can also be assigned to. -.. note:: - - Until version 0.6.0 it was not possible to use a multi-dimensional array or a struct - as an input for an :ref:`external function`. - ``abicoder v2`` made it possible and it's been enabled by default since version 0.8.0 - (before that you had to enable it with ``pragma abicoder v2;``). - - An :ref:`internal function` can accept a - multi-dimensional array or a struct without any restrictions. - .. index:: return array, return string, array, string, array of strings, dynamic array, variably sized array, return struct, struct Return Variables @@ -139,12 +129,16 @@ If you use an early ``return`` to leave a function that has return variables, you must provide return values together with the return statement. .. note:: - You cannot return some types from non-internal functions, notably - multi-dimensional dynamic arrays and structs. If you enable the - ABI coder v2 by adding ``pragma abicoder v2;`` - to your source file then more types are available, but - ``mapping`` types are still limited to inside a single contract and you - cannot transfer them. + You cannot return some types from non-internal functions. + This includes the types listed below and any composite types that recursively contain them: + + - mappings, + - internal function types, + - reference types with location set to ``storage``, + - multi-dimensional arrays (applies only to :ref:`ABI coder v1 `), + - structs (applies only to :ref:`ABI coder v1 `). + + This restriction does not apply to library functions because of their different :ref:`internal ABI `. .. _multi-return: diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 729951142..cd231c1fc 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -56,7 +56,7 @@ you have to add the pragma to all your files if you want to enable it in your whole project. If you :ref:`import` another file, the pragma from that file does *not* automatically apply to the importing file. -.. index:: ! pragma, version +.. index:: ! pragma;version .. _version_pragma: @@ -91,6 +91,9 @@ these follow the same syntax used by `npm