diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-06-22 03:03:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-22 03:03:03 +0800 |
commit | ae43330b62742c5ac799018d1793b5bb0943ee8a (patch) | |
tree | 6b6d666f0a18ed0e1b25b75beb5a1b5cc44f8b88 | |
parent | ad593fdf1996618f8f0f09d69f90e2ed5511a403 (diff) | |
parent | 72e87423db8d938a4ef5eea92a56332c607accdb (diff) | |
download | dexon-solidity-ae43330b62742c5ac799018d1793b5bb0943ee8a.tar.gz dexon-solidity-ae43330b62742c5ac799018d1793b5bb0943ee8a.tar.zst dexon-solidity-ae43330b62742c5ac799018d1793b5bb0943ee8a.zip |
Merge pull request #4328 from ethereum/disallow-years
[BREAKING] Disallow the years unit denomination properly
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | docs/units-and-global-variables.rst | 2 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 16 | ||||
-rw-r--r-- | test/contracts/AuctionRegistrar.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/denominations/denominations.sol | 3 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/denominations/deprecated_year.sol | 2 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/denominations/deprecated_year_050.sol | 6 |
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. |