aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-07-14 23:43:13 +0800
committerchriseth <c@ethdev.com>2015-07-14 23:43:13 +0800
commitcd264b72ab9aae337ed9e0887cd0449dfa82f2b3 (patch)
tree0743b25b65d827b2c8a33735b580a155577b1e5c
parent27b951842342beed9d6876a2786998dc2e8d6189 (diff)
downloaddexon-solidity-cd264b72ab9aae337ed9e0887cd0449dfa82f2b3.tar.gz
dexon-solidity-cd264b72ab9aae337ed9e0887cd0449dfa82f2b3.tar.zst
dexon-solidity-cd264b72ab9aae337ed9e0887cd0449dfa82f2b3.zip
Check whether a literal is a valid literal before using it.
Fixes #2078
-rw-r--r--libsolidity/SolidityNameAndTypeResolution.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp
index 1e40ee4f..0f5e4800 100644
--- a/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2110,6 +2110,30 @@ BOOST_AUTO_TEST_CASE(literal_strings)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
+BOOST_AUTO_TEST_CASE(invalid_integer_literal_fraction)
+{
+ char const* text = R"(
+ contract Foo {
+ function f() {
+ var x = 1.20;
+ }
+ }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
+BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp)
+{
+ char const* text = R"(
+ contract Foo {
+ function f() {
+ var x = 1e2;
+ }
+ }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}