From 8c6bbf607f11d12dd0a085298ec6472b92a24724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 25 Mar 2021 18:57:13 +0100 Subject: [PATCH] docs: Explain that public library functions cannot be called internally from the outside --- docs/contracts/libraries.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/contracts/libraries.rst b/docs/contracts/libraries.rst index 063bc062b..88e13d90c 100644 --- a/docs/contracts/libraries.rst +++ b/docs/contracts/libraries.rst @@ -38,6 +38,12 @@ To realize this in the EVM, code of internal library functions and all functions called from therein will at compile time be included in the calling contract, and a regular ``JUMP`` call will be used instead of a ``DELEGATECALL``. +.. note:: + The inheritance analogy breaks down when it comes to public functions. + Calling a public library function with ``L.f()`` results in an external call (``DELEGATECALL`` + to be precise). + In contrast, ``A.f()`` is an internal call when ``A`` is a base contract of the current contract. + .. index:: using for, set The following example illustrates how to use libraries (but using a manual method,