From b7634faa3d818453fd3c5f36ae077af9107a9e22 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Thu, 6 Jun 2019 10:36:41 +0200 Subject: [PATCH] Improve error message for delegatecall.value --- libsolidity/analysis/TypeChecker.cpp | 5 +++++ .../297_library_functions_do_not_have_value.sol | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index dc05ce18f..8069bd13b 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2065,6 +2065,11 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) { if (funType->kind() == FunctionType::Kind::Creation) errorMsg = "Constructor for " + t.front()->toString() + " must be payable for member \"value\" to be available."; + else if ( + funType->kind() == FunctionType::Kind::DelegateCall || + funType->kind() == FunctionType::Kind::BareDelegateCall + ) + errorMsg = "Member \"value\" is not allowed in delegated calls due to \"msg.value\" persisting."; else errorMsg = "Member \"value\" is only available for payable functions."; } diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol index dfb706417..6e6546c99 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/297_library_functions_do_not_have_value.sol @@ -5,4 +5,4 @@ contract test { } } // ---- -// TypeError: (87-96): Member "value" is only available for payable functions. +// TypeError: (87-96): Member "value" is not allowed in delegated calls due to "msg.value" persisting.