aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-07-12 01:08:11 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-10-19 09:20:30 +0800
commit10677125ae5b2c211d22add52022ebd5a7cc8260 (patch)
tree4d281f0c7635f9805255457a22d0790d66970015
parent7454a766b37951674095afdd0c8573713e2511a4 (diff)
downloaddexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.tar
dexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.tar.gz
dexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.tar.bz2
dexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.tar.lz
dexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.tar.xz
dexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.tar.zst
dexon-solidity-10677125ae5b2c211d22add52022ebd5a7cc8260.zip
Turn usage of callcode into an error as experimental 0.5.0 feature
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/StaticAnalyzer.cpp16
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp10
3 files changed, 23 insertions, 4 deletions
diff --git a/Changelog.md b/Changelog.md
index cb81d975..68b9973f 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,6 +1,7 @@
### 0.4.19 (unreleased)
Features:
+ * Syntax Checker: Turn the usage of ``callcode`` into an error as experimental 0.5.0 feature.
Bugfixes:
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp
index ffa538b6..bd8ee597 100644
--- a/libsolidity/analysis/StaticAnalyzer.cpp
+++ b/libsolidity/analysis/StaticAnalyzer.cpp
@@ -150,10 +150,18 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
if (_memberAccess.memberName() == "callcode")
if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get()))
if (type->kind() == FunctionType::Kind::BareCallCode)
- m_errorReporter.warning(
- _memberAccess.location(),
- "\"callcode\" has been deprecated in favour of \"delegatecall\"."
- );
+ {
+ if (m_currentContract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
+ m_errorReporter.typeError(
+ _memberAccess.location(),
+ "\"callcode\" has been deprecated in favour of \"delegatecall\"."
+ );
+ else
+ m_errorReporter.warning(
+ _memberAccess.location(),
+ "\"callcode\" has been deprecated in favour of \"delegatecall\"."
+ );
+ }
if (m_constructor && m_currentContract)
if (ContractType const* type = dynamic_cast<ContractType const*>(_memberAccess.expression().annotation().type.get()))
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 9b0647bf..9b5ea349 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -4783,6 +4783,16 @@ BOOST_AUTO_TEST_CASE(warn_about_callcode)
}
)";
CHECK_WARNING(text, "\"callcode\" has been deprecated in favour of \"delegatecall\"");
+ text = R"(
+ pragma experimental "v0.5.0";
+ contract test {
+ function f() pure public {
+ var x = address(0x12).callcode;
+ x;
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "\"callcode\" has been deprecated in favour of \"delegatecall\"");
}
BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_function)