diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:14:58 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:15 +0800 |
commit | 8e9a9ad5e9c4ab4fe08626ef3972983b69b198a4 (patch) | |
tree | 078cd12e24aa86b53693d59d05ed484dd10f4c22 | |
parent | 9dedbb41541b1a7c7849f2d601915e3bcc767b70 (diff) | |
download | dexon-solidity-8e9a9ad5e9c4ab4fe08626ef3972983b69b198a4.tar.gz dexon-solidity-8e9a9ad5e9c4ab4fe08626ef3972983b69b198a4.tar.zst dexon-solidity-8e9a9ad5e9c4ab4fe08626ef3972983b69b198a4.zip |
Explicit conversion from int to Enum
-rw-r--r-- | SolidityNameAndTypeResolution.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index c912939f..f3edfc31 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -1039,6 +1039,23 @@ BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay) BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text)); } +BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay) +{ + char const* text = R"( + contract test { + enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }; + function test() + { + a = 2; + b = ActionChoices(a); + } + uint256 a; + ActionChoices b; + } + )"; + BOOST_CHECK_NO_THROW(parseTextAndResolveNamesWithChecks(text)); +} + BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay) { char const* text = R"( |