Skip to content

Commit

Permalink
Turn usage of callcode into an error as experimental 0.5.0 feature
Browse files Browse the repository at this point in the history
axic committed Oct 19, 2017
1 parent 7454a76 commit 1067712
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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:

16 changes: 12 additions & 4 deletions libsolidity/analysis/StaticAnalyzer.cpp
Original file line number Diff line number Diff line change
@@ -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()))
10 changes: 10 additions & 0 deletions test/libsolidity/SolidityNameAndTypeResolution.cpp
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1067712

Please sign in to comment.