aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md3
-rw-r--r--libsolidity/analysis/TypeChecker.cpp12
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp61
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions.sol4
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions_050.sol15
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals.sol21
-rw-r--r--test/libsolidity/syntaxTests/tight_packing_literals_fine.sol14
7 files changed, 19 insertions, 111 deletions
diff --git a/Changelog.md b/Changelog.md
index d3715237..8c895ee0 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -4,12 +4,13 @@ Breaking Changes:
* Code Generator: Signed right shift uses proper arithmetic shift, i.e. rounding towards negative infinity. Warning: this may silently change the semantics of existing code!
* Commandline interface: Require ``-`` if standard input is used as source.
* General: ``continue`` in a ``do...while`` loop jumps to the condition (it used to jump to the loop body). Warning: this may silently change the semantics of existing code.
+ * General: Disallow ``sha3`` and ``suicide`` aliases.
* General: Introduce ``emit`` as a keyword instead of parsing it as identifier.
* General: New keywords: ``calldata``
* General: New reserved keywords: ``alias``, ``apply``, ``auto``, ``copyof``, ``define``, ``immutable``,
``implements``, ``macro``, ``mutable``, ``override``, ``partial``, ``promise``, ``reference``, ``sealed``,
``sizeof``, ``supports``, ``typedef`` and ``unchecked``.
- * General: Remove assembly instructions ``sha3`` and ``suicide``
+ * General: Remove assembly instruction aliases ``sha3`` and ``suicide``
* Parser: Disallow trailing dots that are not followed by a number.
* Type Checker: Disallow arithmetic operations for boolean variables.
* Type Checker: Disallow conversions between ``bytesX`` and ``uintY`` of different size.
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 521e8bd9..671e4030 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1708,18 +1708,10 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
{
- string msg;
if (functionName->name() == "sha3" && functionType->kind() == FunctionType::Kind::SHA3)
- msg = "\"sha3\" has been deprecated in favour of \"keccak256\"";
+ m_errorReporter.typeError(_functionCall.location(), "\"sha3\" has been deprecated in favour of \"keccak256\"");
else if (functionName->name() == "suicide" && functionType->kind() == FunctionType::Kind::Selfdestruct)
- msg = "\"suicide\" has been deprecated in favour of \"selfdestruct\"";
- if (!msg.empty())
- {
- if (v050)
- m_errorReporter.typeError(_functionCall.location(), msg);
- else
- m_errorReporter.warning(_functionCall.location(), msg);
- }
+ m_errorReporter.typeError(_functionCall.location(), "\"suicide\" has been deprecated in favour of \"selfdestruct\"");
}
if (!m_insideEmitStatement && functionType->kind() == FunctionType::Kind::Event)
{
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index a4c02888..2afb4e1c 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1971,25 +1971,6 @@ BOOST_AUTO_TEST_CASE(log_in_constructor)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2)));
}
-BOOST_AUTO_TEST_CASE(suicide)
-{
- char const* sourceCode = R"(
- contract test {
- function test() payable {}
- function a(address receiver) returns (uint ret) {
- suicide(receiver);
- return 10;
- }
- }
- )";
- u256 amount(130);
- compileAndRun(sourceCode, amount);
- u160 address(23);
- ABI_CHECK(callContractFunction("a(address)", address), bytes());
- BOOST_CHECK(!addressHasCode(m_contractAddress));
- BOOST_CHECK_EQUAL(balanceAt(address), amount);
-}
-
BOOST_AUTO_TEST_CASE(selfdestruct)
{
char const* sourceCode = R"(
@@ -2028,23 +2009,6 @@ BOOST_AUTO_TEST_CASE(keccak256)
testContractAgainstCpp("a(bytes32)", f, u256(-1));
}
-BOOST_AUTO_TEST_CASE(sha3)
-{
- char const* sourceCode = R"(
- contract test {
- // to confuse the optimiser
- function b(bytes32 input) returns (bytes32) {
- return sha3(input);
- }
- function a(bytes32 input) returns (bool) {
- return keccak256(input) == b(input);
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_REQUIRE(callContractFunction("a(bytes32)", u256(42)) == encodeArgs(true));
-}
-
BOOST_AUTO_TEST_CASE(sha256)
{
char const* sourceCode = R"(
@@ -3760,27 +3724,6 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes)
));
}
-BOOST_AUTO_TEST_CASE(sha3_multiple_arguments)
-{
- char const* sourceCode = R"(
- contract c {
- function foo(uint a, uint b, uint c) returns (bytes32 d)
- {
- d = sha3(a, b, c);
- }
- }
- )";
- compileAndRun(sourceCode);
-
- ABI_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13), encodeArgs(
- dev::keccak256(
- toBigEndian(u256(10)) +
- toBigEndian(u256(12)) +
- toBigEndian(u256(13))
- )
- ));
-}
-
BOOST_AUTO_TEST_CASE(generic_call)
{
char const* sourceCode = R"**(
@@ -11642,13 +11585,13 @@ BOOST_AUTO_TEST_CASE(delegatecall_return_value)
return value;
}
function get_delegated() external returns (bool) {
- return this.delegatecall(bytes4(sha3("get()")));
+ return this.delegatecall(bytes4(keccak256("get()")));
}
function assert0() external view {
assert(value == 0);
}
function assert0_delegated() external returns (bool) {
- return this.delegatecall(bytes4(sha3("assert0()")));
+ return this.delegatecall(bytes4(keccak256("assert0()")));
}
}
)DELIMITER";
diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol
index 9df2b43c..ff3af7d2 100644
--- a/test/libsolidity/syntaxTests/deprecated_functions.sol
+++ b/test/libsolidity/syntaxTests/deprecated_functions.sol
@@ -8,5 +8,5 @@ contract test {
}
}
// ----
-// Warning: (58-64): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (99-109): "suicide" has been deprecated in favour of "selfdestruct"
+// TypeError: (58-64): "sha3" has been deprecated in favour of "keccak256"
+// TypeError: (99-109): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/deprecated_functions_050.sol b/test/libsolidity/syntaxTests/deprecated_functions_050.sol
deleted file mode 100644
index b28e5abb..00000000
--- a/test/libsolidity/syntaxTests/deprecated_functions_050.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-pragma experimental "v0.5.0";
-contract test {
- function f() pure public {
- bytes32 x = sha3(uint8(1));
- x;
- }
- function g() public {
- suicide(1);
- }
-}
-// ----
-// TypeError: (88-102): "sha3" has been deprecated in favour of "keccak256"
-// TypeError: (88-102): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// TypeError: (88-102): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// TypeError: (137-147): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals.sol b/test/libsolidity/syntaxTests/tight_packing_literals.sol
index a190adc3..d6c7f0ba 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals.sol
@@ -2,9 +2,6 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(1);
}
- function g() pure public returns (bytes32) {
- return sha3(1);
- }
function h() pure public returns (bytes32) {
return sha256(1);
}
@@ -20,14 +17,10 @@ contract C {
// Warning: (87-88): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
// Warning: (77-89): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
// Warning: (77-89): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (161-168): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (166-167): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (161-168): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (161-168): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (247-248): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (240-249): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (240-249): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (331-332): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
-// Warning: (321-333): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (321-333): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
-// Warning: (420-421): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (168-169): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (161-170): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (161-170): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
+// Warning: (252-253): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (242-254): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (242-254): The provided argument of type int_const 1 is not implicitly convertible to expected type bytes memory.
+// Warning: (341-342): The type of "int_const 1" was inferred as uint8. This is probably not desired. Use an explicit type to silence this warning.
diff --git a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
index 2b9b688a..27665b52 100644
--- a/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
+++ b/test/libsolidity/syntaxTests/tight_packing_literals_fine.sol
@@ -2,9 +2,6 @@ contract C {
function f() pure public returns (bytes32) {
return keccak256(uint8(1));
}
- function g() pure public returns (bytes32) {
- return sha3(uint8(1));
- }
function h() pure public returns (bytes32) {
return sha256(uint8(1));
}
@@ -21,10 +18,7 @@ contract C {
// ----
// Warning: (77-96): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
// Warning: (77-96): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (168-182): "sha3" has been deprecated in favour of "keccak256"
-// Warning: (168-182): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (168-182): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (254-270): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (254-270): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
-// Warning: (342-361): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
-// Warning: (342-361): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
+// Warning: (168-184): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (168-184): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.
+// Warning: (256-275): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
+// Warning: (256-275): The provided argument of type uint8 is not implicitly convertible to expected type bytes memory.