aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-11-29 17:05:52 +0800
committerLeonardo Alt <leo@ethereum.org>2018-11-29 21:29:13 +0800
commit67bbcefe6c104d60b42d35c61d42fb979f69fe89 (patch)
tree2f0a0f6b33bdabcb8fe70ed9aeb02f46086ee717 /libsolidity
parent6b11ef188739302bc9a2a553aee25a172325e0be (diff)
downloaddexon-solidity-67bbcefe6c104d60b42d35c61d42fb979f69fe89.tar.gz
dexon-solidity-67bbcefe6c104d60b42d35c61d42fb979f69fe89.tar.zst
dexon-solidity-67bbcefe6c104d60b42d35c61d42fb979f69fe89.zip
Report deprecation error on functions sha3 and suicide also without call.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index fcc6746f..16b6a55e 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1824,26 +1824,6 @@ void TypeChecker::typeCheckFunctionCall(
"\"staticcall\" is not supported by the VM version."
);
- // Check for deprecated function names
- if (_functionType->kind() == FunctionType::Kind::KECCAK256)
- {
- if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
- if (functionName->name() == "sha3")
- m_errorReporter.typeError(
- _functionCall.location(),
- "\"sha3\" has been deprecated in favour of \"keccak256\""
- );
- }
- else if (_functionType->kind() == FunctionType::Kind::Selfdestruct)
- {
- if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
- if (functionName->name() == "suicide")
- m_errorReporter.typeError(
- _functionCall.location(),
- "\"suicide\" has been deprecated in favour of \"selfdestruct\""
- );
- }
-
// Check for event outside of emit statement
if (!m_insideEmitStatement && _functionType->kind() == FunctionType::Kind::Event)
m_errorReporter.typeError(
@@ -2639,6 +2619,23 @@ bool TypeChecker::visit(Identifier const& _identifier)
else if (dynamic_cast<MagicVariableDeclaration const*>(annotation.referencedDeclaration))
if (dynamic_cast<FunctionType const*>(annotation.type.get()))
annotation.isPure = true;
+
+ // Check for deprecated function names.
+ // The check is done here for the case without an actual function call.
+ if (FunctionType const* fType = dynamic_cast<FunctionType const*>(_identifier.annotation().type.get()))
+ {
+ if (_identifier.name() == "sha3" && fType->kind() == FunctionType::Kind::KECCAK256)
+ m_errorReporter.typeError(
+ _identifier.location(),
+ "\"sha3\" has been deprecated in favour of \"keccak256\""
+ );
+ else if (_identifier.name() == "suicide" && fType->kind() == FunctionType::Kind::Selfdestruct)
+ m_errorReporter.typeError(
+ _identifier.location(),
+ "\"suicide\" has been deprecated in favour of \"selfdestruct\""
+ );
+ }
+
return false;
}