diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-27 09:10:24 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-27 09:10:24 +0800 |
commit | 5c0d82059f50cb6ac67171ca075f394acae27228 (patch) | |
tree | c0a81bfc65d3a991ddced5a954a5c6a63b6f39f3 | |
parent | 1f5eb4ba59891387c2dfcc10103c2f187bf2b4ee (diff) | |
download | dexon-solidity-5c0d82059f50cb6ac67171ca075f394acae27228.tar.gz dexon-solidity-5c0d82059f50cb6ac67171ca075f394acae27228.tar.zst dexon-solidity-5c0d82059f50cb6ac67171ca075f394acae27228.zip |
Turn throw into a syntax error for 0.5.0
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/SyntaxChecker.cpp | 16 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 11 |
3 files changed, 23 insertions, 5 deletions
diff --git a/Changelog.md b/Changelog.md index 3af3a99d..acd3aa54 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Features: * Type Checker: Disallow uninitialized storage pointers as experimental 0.5.0 feature. * Support and recommend using ``emit EventName();`` to call events explicitly. * Syntax Analyser: Do not warn about experimental features if they do not concern code generation. + * Syntax Checker: Mark ``throw`` as an error as experimental 0.5.0 feature. Bugfixes: * Assembly: Raise error on oversized number literals in assembly. diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 74834ba4..1dcfeb27 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -174,10 +174,18 @@ bool SyntaxChecker::visit(Break const& _breakStatement) bool SyntaxChecker::visit(Throw const& _throwStatement) { - m_errorReporter.warning( - _throwStatement.location(), - "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." - ); + 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()\"." + ); return true; } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 93abee0d..be147e48 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -6332,7 +6332,16 @@ BOOST_AUTO_TEST_CASE(warn_about_throw) } } )"; - CHECK_WARNING(text, "\"throw\" is deprecated"); + CHECK_WARNING(text, "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\""); + text = R"( + pragma experimental "v0.5.0"; + contract C { + function f() pure public { + throw; + } + } + )"; + CHECK_ERROR(text, SyntaxError, "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\""); } BOOST_AUTO_TEST_CASE(bare_revert) |