From 21e97da2949a421987b0c6ad75bd401ce1dad0ab Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 11 Jul 2018 15:06:31 +0100 Subject: Deprecate the throw statement --- .../syntaxTests/controlFlow/storageReturn/throw_fine.sol | 9 --------- .../nameAndTypeResolution/426_throw_is_deprecated.sol | 2 +- .../nameAndTypeResolution/427_throw_is_deprecated_v050.sol | 8 -------- 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol (limited to 'test/libsolidity') diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol deleted file mode 100644 index 4cecc27c..00000000 --- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/throw_fine.sol +++ /dev/null @@ -1,9 +0,0 @@ -contract C { - struct S { bool f; } - S s; - function f() internal pure returns (S storage) { - throw; - } -} -// ---- -// Warning: (108-113): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol index 510c0d01..24f36c5b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/426_throw_is_deprecated.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// Warning: (52-57): "throw" is deprecated in favour of "revert()", "require()" and "assert()". +// SyntaxError: (52-57): "throw" is deprecated in favour of "revert()", "require()" and "assert()". diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol deleted file mode 100644 index 170d47d9..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/427_throw_is_deprecated_v050.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - throw; - } -} -// ---- -// SyntaxError: (82-87): "throw" is deprecated in favour of "revert()", "require()" and "assert()". -- cgit From aa08460d94f0e3ac8e067f89786175fb5ebba73b Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 12 Jul 2018 00:43:19 +0100 Subject: Replace throw with revert() in end-to-end tests --- test/libsolidity/SolidityEndToEndTest.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index be74c5ff..9317eedd 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -2095,7 +2095,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether) contract C { function () external payable { - throw; + revert(); } } )"; @@ -7741,7 +7741,7 @@ BOOST_AUTO_TEST_CASE(simple_throw) if (x > 10) return x + 10; else - throw; + revert(); return 2; } } @@ -9603,7 +9603,7 @@ BOOST_AUTO_TEST_CASE(mutex) contract mutexed { bool locked; modifier protected { - if (locked) throw; + if (locked) revert(); locked = true; _; locked = false; @@ -9615,16 +9615,16 @@ BOOST_AUTO_TEST_CASE(mutex) function withdraw(uint amount) protected returns (uint) { // NOTE: It is very bad practice to write this function this way. // Please refer to the documentation of how to do this properly. - if (amount > shares) throw; - if (!msg.sender.call.value(amount)("")) throw; + if (amount > shares) revert(); + if (!msg.sender.call.value(amount)("")) revert(); shares -= amount; return shares; } function withdrawUnprotected(uint amount) public returns (uint) { // NOTE: It is very bad practice to write this function this way. // Please refer to the documentation of how to do this properly. - if (amount > shares) throw; - if (!msg.sender.call.value(amount)("")) throw; + if (amount > shares) revert(); + if (!msg.sender.call.value(amount)("")) revert(); shares -= amount; return shares; } @@ -11159,7 +11159,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_in_modifiers) a := 2 } if (a != 2) - throw; + revert(); _; } function f() m public returns (bool) { -- cgit