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 --- Changelog.md | 1 + libsolidity/analysis/SyntaxChecker.cpp | 16 ++++------------ .../syntaxTests/controlFlow/storageReturn/throw_fine.sol | 9 --------- .../nameAndTypeResolution/426_throw_is_deprecated.sol | 2 +- .../427_throw_is_deprecated_v050.sol | 8 -------- 5 files changed, 6 insertions(+), 30 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 diff --git a/Changelog.md b/Changelog.md index 35fd42b4..f3c06d90 100644 --- a/Changelog.md +++ b/Changelog.md @@ -20,6 +20,7 @@ Breaking Changes: * General: Disallow raw ``callcode`` (was already deprecated in 0.4.12). It is still possible to use it via inline assembly. * General: Disallow ``var`` keyword. * General: Disallow ``sha3`` and ``suicide`` aliases. + * General: Disallow the ``throw`` statement. This was already the case in the experimental 0.5.0 mode. * General: Disallow the ``years`` unit denomination (was already deprecated in 0.4.24) * General: Introduce ``emit`` as a keyword instead of parsing it as identifier. * General: New keywords: ``calldata`` diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index e33aafed..fba18a45 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -175,18 +175,10 @@ bool SyntaxChecker::visit(Break const& _breakStatement) bool SyntaxChecker::visit(Throw const& _throwStatement) { - bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050); - - if (v050) - m_errorReporter.syntaxError( - _throwStatement.location(), - "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." - ); - else - m_errorReporter.warning( - _throwStatement.location(), - "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." - ); + m_errorReporter.syntaxError( + _throwStatement.location(), + "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." + ); return true; } 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 v1.2.3