aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-06-21 06:01:40 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-06-22 02:21:02 +0800
commit72e87423db8d938a4ef5eea92a56332c607accdb (patch)
treeb35087edce7175dede56de0df7a8b457b020c0e3
parent32f2db780c6d4d5ca507c595c8f15cacb51972c7 (diff)
downloaddexon-solidity-72e87423db8d938a4ef5eea92a56332c607accdb.tar.gz
dexon-solidity-72e87423db8d938a4ef5eea92a56332c607accdb.tar.zst
dexon-solidity-72e87423db8d938a4ef5eea92a56332c607accdb.zip
Disallow the years unit denomination properly
-rw-r--r--Changelog.md1
-rw-r--r--docs/units-and-global-variables.rst2
-rw-r--r--libsolidity/analysis/TypeChecker.cpp16
-rw-r--r--test/contracts/AuctionRegistrar.cpp2
-rw-r--r--test/libsolidity/syntaxTests/denominations/denominations.sol3
-rw-r--r--test/libsolidity/syntaxTests/denominations/deprecated_year.sol2
-rw-r--r--test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol6
7 files changed, 9 insertions, 23 deletions
diff --git a/Changelog.md b/Changelog.md
index 07b74ddc..1e9b2787 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -10,6 +10,7 @@ Breaking Changes:
* General: Disallow declaring empty structs.
* General: Disallow raw ``callcode`` (was already deprecated in 0.4.12). It is still possible to use it via inline assembly.
* General: Disallow ``sha3`` and ``suicide`` aliases.
+ * 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``
* General: New reserved keywords: ``alias``, ``apply``, ``auto``, ``copyof``, ``define``, ``immutable``,
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index a6f8ca87..3b0be438 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -32,7 +32,7 @@ Due to the fact that leap seconds cannot be predicted, an exact calendar
library has to be updated by an external oracle.
.. note::
- The suffix ``years`` has been deprecated due to the reasons above.
+ The suffix ``years`` has been deprecated due to the reasons above and cannot be used starting version 0.5.0.
These suffixes cannot be applied to variables. If you want to
interpret some input variable in e.g. days, you can do it in the following way::
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index c19ca76d..19e931f2 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2316,18 +2316,10 @@ void TypeChecker::endVisit(Literal const& _literal)
}
if (_literal.subDenomination() == Literal::SubDenomination::Year)
- {
- if (v050)
- m_errorReporter.typeError(
- _literal.location(),
- "Using \"years\" as a unit denomination is deprecated."
- );
- else
- m_errorReporter.warning(
- _literal.location(),
- "Using \"years\" as a unit denomination is deprecated."
- );
- }
+ m_errorReporter.typeError(
+ _literal.location(),
+ "Using \"years\" as a unit denomination is deprecated."
+ );
if (!_literal.annotation().type)
_literal.annotation().type = Type::forLiteral(_literal);
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 5e4991e2..33b392d4 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -109,7 +109,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
uint renewalDate;
}
- uint constant c_renewalInterval = 1 years;
+ uint constant c_renewalInterval = 365 days;
uint constant c_freeBytes = 12;
function Registrar() {
diff --git a/test/libsolidity/syntaxTests/denominations/denominations.sol b/test/libsolidity/syntaxTests/denominations/denominations.sol
index 6d1aa2f3..43049a14 100644
--- a/test/libsolidity/syntaxTests/denominations/denominations.sol
+++ b/test/libsolidity/syntaxTests/denominations/denominations.sol
@@ -1,7 +1,6 @@
contract C {
uint constant a = 1 wei + 2 szabo + 3 finney + 4 ether;
- uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks + 6 years;
+ uint constant b = 1 seconds + 2 minutes + 3 hours + 4 days + 5 weeks;
uint constant c = 2 szabo / 1 seconds + 3 finney * 3 hours;
}
// ----
-// Warning: (142-149): Using "years" as a unit denomination is deprecated.
diff --git a/test/libsolidity/syntaxTests/denominations/deprecated_year.sol b/test/libsolidity/syntaxTests/denominations/deprecated_year.sol
index 30e86535..691c0cb0 100644
--- a/test/libsolidity/syntaxTests/denominations/deprecated_year.sol
+++ b/test/libsolidity/syntaxTests/denominations/deprecated_year.sol
@@ -2,4 +2,4 @@ contract C {
uint constant a = 3 years;
}
// ----
-// Warning: (32-39): Using "years" as a unit denomination is deprecated.
+// TypeError: (32-39): Using "years" as a unit denomination is deprecated.
diff --git a/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol b/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol
deleted file mode 100644
index 4baaeaa3..00000000
--- a/test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol
+++ /dev/null
@@ -1,6 +0,0 @@
-pragma experimental "v0.5.0";
-contract C {
- uint constant a = 3 years;
-}
-// ----
-// TypeError: (62-69): Using "years" as a unit denomination is deprecated.