aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-07-06 04:24:45 +0800
committerGitHub <noreply@github.com>2017-07-06 04:24:45 +0800
commiteca2655cae7d6fcefdb53630f96768acdaf937a4 (patch)
tree81d1fbebb3b698fb49970e63a8c04029fc10d56a
parent4bde6fa96122a308296e00dfb32da25905c5ef34 (diff)
parent0400e61e284bd595384d859752d97993b1f5ca45 (diff)
downloaddexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.tar
dexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.tar.gz
dexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.tar.bz2
dexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.tar.lz
dexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.tar.xz
dexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.tar.zst
dexon-solidity-eca2655cae7d6fcefdb53630f96768acdaf937a4.zip
Merge pull request #2529 from ethereum/warnThrow
Deprecate throw.
-rw-r--r--Changelog.md3
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp10
-rw-r--r--libsolidity/analysis/SyntaxChecker.h3
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp12
4 files changed, 27 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index c5085f1b..8ba06aaf 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,11 +1,12 @@
### 0.4.13 (unreleased)
Features:
+ * Syntax Checker: Deprecated "throw" in favour of require(), assert() and revert().
* Type Checker: Warn if a local storage reference variable does not explicitly use the keyword ``storage``.
Bugfixes:
- * Compiler Interface: Only output AST if analysis was successful.
* Code Generator: Correctly unregister modifier variables.
+ * Compiler Interface: Only output AST if analysis was successful.
* Error Output: Do not omit the error type.
### 0.4.12 (2017-07-03)
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 02e2fdcf..bde0e616 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -135,6 +135,16 @@ bool SyntaxChecker::visit(Break const& _breakStatement)
return true;
}
+bool SyntaxChecker::visit(Throw const& _throwStatement)
+{
+ m_errorReporter.warning(
+ _throwStatement.location(),
+ "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"."
+ );
+
+ return true;
+}
+
bool SyntaxChecker::visit(UnaryOperation const& _operation)
{
if (_operation.getOperator() == Token::Add)
diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h
index ec6ac434..fb5cc6d7 100644
--- a/libsolidity/analysis/SyntaxChecker.h
+++ b/libsolidity/analysis/SyntaxChecker.h
@@ -33,6 +33,7 @@ namespace solidity
* - whether continue/break is in a for/while loop.
* - whether a modifier contains at least one '_'
* - issues deprecation warnings for unary '+'
+ * - issues deprecation warning for throw
*/
class SyntaxChecker: private ASTConstVisitor
{
@@ -59,6 +60,8 @@ private:
virtual bool visit(Continue const& _continueStatement) override;
virtual bool visit(Break const& _breakStatement) override;
+ virtual bool visit(Throw const& _throwStatement) override;
+
virtual bool visit(UnaryOperation const& _operation) override;
virtual bool visit(PlaceholderStatement const& _placeholderStatement) override;
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index e04d50e8..108128f7 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -5860,6 +5860,18 @@ BOOST_AUTO_TEST_CASE(using_interface_complex)
success(text);
}
+BOOST_AUTO_TEST_CASE(warn_about_throw)
+{
+ char const* text = R"(
+ contract C {
+ function f() {
+ throw;
+ }
+ }
+ )";
+ CHECK_WARNING(text, "\"throw\" is deprecated");
+}
+
BOOST_AUTO_TEST_CASE(bare_revert)
{
char const* text = R"(