aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-16 23:28:49 +0800
committerchriseth <chris@ethereum.org>2018-09-04 00:35:57 +0800
commit431c2fbcf370926d6c3e7e93667d8472f2f6b73b (patch)
treece2e41de6ad496729b62a493057e72a2413ad215
parent75a92b0ffd0946c17a27a58e6e02abe96cd3fa00 (diff)
downloaddexon-solidity-431c2fbcf370926d6c3e7e93667d8472f2f6b73b.tar.gz
dexon-solidity-431c2fbcf370926d6c3e7e93667d8472f2f6b73b.tar.zst
dexon-solidity-431c2fbcf370926d6c3e7e93667d8472f2f6b73b.zip
Turn warning into error.
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp12
-rw-r--r--test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol2
-rw-r--r--test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol2
4 files changed, 10 insertions, 8 deletions
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 291b4681..be6b7ef7 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -262,16 +262,18 @@ void ViewPureChecker::reportMutability(
if (m_currentFunction->isPublic() && m_currentFunction->inContractKind() != ContractDefinition::ContractKind::Library)
{
if (_nestedLocation)
- m_errorReporter.warning(
+ m_errorReporter.typeError(
_location,
- "This modifier uses \"msg.value\" and thus the function should be payable.",
- SecondarySourceLocation().append("\"msg.value\" appears here inside the modifier.", *_nestedLocation)
+ SecondarySourceLocation().append("\"msg.value\" appears here inside the modifier.", *_nestedLocation),
+ "This modifier uses \"msg.value\" and thus the function has to be payable or internal."
);
else
- m_errorReporter.warning(
+ m_errorReporter.typeError(
_location,
- "\"msg.value\" used in non-payable function. Do you want to add the \"payable\" modifier to this function?"
+ "\"msg.value\" can only be used in payable public functions. Make the function "
+ "\"payable\" or use an internal function to avoid this error."
);
+ m_errors = true;
}
}
else
diff --git a/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol
index 49a3139c..8430c5c3 100644
--- a/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol
+++ b/test/libsolidity/syntaxTests/memberLookup/msg_value_modifier_view.sol
@@ -3,4 +3,4 @@ contract C {
function f() costs(1 ether) public view {}
}
// ----
-// Warning: (101-115): This modifier uses "msg.value" and thus the function should be payable.
+// TypeError: (101-115): This modifier uses "msg.value" and thus the function has to be payable or internal.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol
index 4e1f62e1..c56ad25f 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/397_warns_msg_value_in_non_payable_public_function.sol
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
-// Warning: (52-61): "msg.value" used in non-payable function. Do you want to add the "payable" modifier to this function?
+// TypeError: (52-61): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
diff --git a/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol
index 4cad4439..613b0198 100644
--- a/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol
+++ b/test/libsolidity/syntaxTests/viewPureChecker/msg_value_modifier_view.sol
@@ -3,4 +3,4 @@ contract C {
function f() m(1 ether, msg.value) public view {}
}
// ----
-// Warning: (118-127): "msg.value" used in non-payable function. Do you want to add the "payable" modifier to this function?
+// TypeError: (118-127): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.