diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-03-05 20:28:57 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-03-05 20:28:57 +0800 |
commit | 29fb5fe1c93ec6a5dd474e47f999236d1a8b6f0e (patch) | |
tree | 28c3e830a86f39b8cdf3e0e5920dab358f07e613 | |
parent | 298bdeec4921bd30c055a790976542989710b867 (diff) | |
download | dexon-solidity-29fb5fe1c93ec6a5dd474e47f999236d1a8b6f0e.tar.gz dexon-solidity-29fb5fe1c93ec6a5dd474e47f999236d1a8b6f0e.tar.zst dexon-solidity-29fb5fe1c93ec6a5dd474e47f999236d1a8b6f0e.zip |
Add test cases for shadowing gasleft with local functions/variables.
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 469211d3..43c9bc9b 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -7434,6 +7434,25 @@ BOOST_AUTO_TEST_CASE(gas_left) CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup in msg"); } +BOOST_AUTO_TEST_CASE(gasleft_as_identifier) +{ + char const* text = R"( + contract C { + function gasleft() public pure returns (bytes32 val) { return "abc"; } + function f() public pure { bytes32 val = gasleft(); assert (val == "abc"); } + } + )"; + CHECK_WARNING(text, "This declaration shadows a builtin symbol."); + + text = R"( + contract C { + uint gasleft; + function f() public { gasleft = 42; } + } + )"; + CHECK_WARNING(text, "This declaration shadows a builtin symbol."); +} + BOOST_AUTO_TEST_CASE(builtin_reject_value) { char const* text = R"( |