aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-30 01:20:39 +0800
committerGitHub <noreply@github.com>2017-09-30 01:20:39 +0800
commitba7c5d2305d3486ddd699637a881ee229627082f (patch)
tree637552965700a6a3d350f2a2626a7d46ab5c3762
parent466cce58dffc66054e9df223f49a9219e6f5f4cd (diff)
parente434437eb71e03483232a55aac8c53928fe63d38 (diff)
downloaddexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.tar
dexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.tar.gz
dexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.tar.bz2
dexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.tar.lz
dexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.tar.xz
dexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.tar.zst
dexon-solidity-ba7c5d2305d3486ddd699637a881ee229627082f.zip
Merge pull request #2939 from roadriverrail/error_unary_plus
Unary + now a synax error (experimental 0.5.0)
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp9
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp25
3 files changed, 34 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index cbcf83ca..008b3c86 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,7 @@
Features:
* Parser: Better error message for unexpected trailing comma in parameter lists.
+ * Syntax Checker: Unary ``+`` is now a syntax error as experimental 0.5.0 feature.
Bugfixes:
* Parser: Fix source location of VariableDeclarationStatement.
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index 187eb26f..0ca4b86c 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -182,8 +182,15 @@ bool SyntaxChecker::visit(Throw const& _throwStatement)
bool SyntaxChecker::visit(UnaryOperation const& _operation)
{
+ bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
+
if (_operation.getOperator() == Token::Add)
- m_errorReporter.warning(_operation.location(), "Use of unary + is deprecated.");
+ {
+ if (v050)
+ m_errorReporter.syntaxError(_operation.location(), "Use of unary + is deprecated.");
+ else
+ m_errorReporter.warning(_operation.location(), "Use of unary + is deprecated.");
+ }
return true;
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 91c2adb1..c3a1ce08 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -4135,6 +4135,8 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
+
+ // Test deprecation warning under < 0.5.0
text = R"(
contract test {
function f() pure public {
@@ -4154,6 +4156,29 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation)
}
)";
CHECK_WARNING(text,"Use of unary + is deprecated");
+
+ // Test syntax error under 0.5.0
+ text = R"(
+ pragma experimental "v0.5.0";
+ contract test {
+ function f() pure public {
+ ufixed16x2 a = +3.25;
+ fixed16x2 b = -3.25;
+ a; b;
+ }
+ }
+ )";
+ CHECK_ERROR(text, SyntaxError, "Use of unary + is deprecated");
+ text = R"(
+ pragma experimental "v0.5.0";
+ contract test {
+ function f(uint x) pure public {
+ uint y = +x;
+ y;
+ }
+ }
+ )";
+ CHECK_ERROR(text, SyntaxError, "Use of unary + is deprecated");
}
BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert)