Merge pull request #3981 from ethereum/years-suffix

The "year" denomination is deprecated
This commit is contained in:
chriseth
2018-04-24 12:12:03 +02:00
committed by GitHub
9 changed files with 52 additions and 19 deletions
@@ -2278,25 +2278,6 @@ BOOST_AUTO_TEST_CASE(explicit_conversion_from_decimal_to_bytesxx)
CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(combining_hex_and_denomination)
{
char const* text = R"(
contract Foo {
uint constant x = 0x01 wei;
}
)";
CHECK_WARNING(text, "Hexadecimal numbers with unit denominations are deprecated.");
char const* textV050 = R"(
pragma experimental "v0.5.0";
contract Foo {
uint constant x = 0x01 wei;
}
)";
CHECK_ERROR(textV050, TypeError, "Hexadecimal numbers cannot be used with unit denominations.");
}
BOOST_AUTO_TEST_CASE(assigning_value_to_const_variable)
{
char const* text = R"(
@@ -0,0 +1,5 @@
contract C {
uint constant x = 0x01 wei;
}
// ----
// Warning: (32-40): Hexadecimal numbers with unit denominations are deprecated. You can use an expression of the form "0x1234 * 1 day" instead.
@@ -0,0 +1,6 @@
pragma experimental "v0.5.0";
contract C {
uint constant x = 0x01 wei;
}
// ----
// TypeError: (62-70): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead.
@@ -0,0 +1,7 @@
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 c = 2 szabo / 1 seconds + 3 finney * 3 hours;
}
// ----
// Warning: (142-149): Using "years" as a unit denomination is deprecated.
@@ -0,0 +1,5 @@
contract C {
uint constant a = 3 years;
}
// ----
// Warning: (32-39): Using "years" as a unit denomination is deprecated.
@@ -0,0 +1,6 @@
pragma experimental "v0.5.0";
contract C {
uint constant a = 3 years;
}
// ----
// TypeError: (62-69): Using "years" as a unit denomination is deprecated.
@@ -0,0 +1,6 @@
contract C {
uint constant a = 4 ether / 3 hours;
ufixed constant b = ufixed(4 ether / 3 hours);
}
// ----
// TypeError: (32-49): Type rational_const 10000000000000000 / 27 is not implicitly convertible to expected type uint256. Try converting to type ufixed256x62 or use an explicit conversion.