diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp index 74a488883..ffa78ed9e 100644 --- a/SolidityNameAndTypeResolution.cpp +++ b/SolidityNameAndTypeResolution.cpp @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(smoke_test) { char const* text = "contract test {\n" " uint256 stateVariable1;\n" - " function fun(uint256 arg1) { var x; uint256 y; }" + " function fun(uint256 arg1) { uint256 y; }" "}\n"; ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(text), "Parsing and Name Resolving Failed"); } @@ -1623,6 +1623,16 @@ BOOST_AUTO_TEST_CASE(bytes0_array) BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); } +BOOST_AUTO_TEST_CASE(uninitialized_var) +{ + char const* sourceCode = R"( + contract C { + function f() returns (uint) { var x; return 2; } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/SolidityParser.cpp b/SolidityParser.cpp index b76f00656..7cd8efce1 100644 --- a/SolidityParser.cpp +++ b/SolidityParser.cpp @@ -841,6 +841,15 @@ BOOST_AUTO_TEST_CASE(constant_is_keyword) BOOST_CHECK_THROW(parseText(text), ParserError); } +BOOST_AUTO_TEST_CASE(var_array) +{ + char const* text = R"( + contract Foo { + function f() { var[] a; } + })"; + BOOST_CHECK_THROW(parseText(text), ParserError); +} + BOOST_AUTO_TEST_SUITE_END() }