From 73fbaa5a3e31d54a6456642223814fa4c044bad1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 22 Jun 2017 15:22:49 +0200 Subject: Test for var i = 0; --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index c8a04539..14bb0810 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1781,6 +1781,28 @@ BOOST_AUTO_TEST_CASE(exp_warn_literal_base) CHECK_SUCCESS(sourceCode); } + +BOOST_AUTO_TEST_CASE(warn_var_from_zero) +{ + char const* sourceCode = R"( + contract test { + function f() returns (uint) { + var i = 1; + return i; + } + } + )"; + CHECK_WARNING(sourceCode, "type uint8, which can only hold"); + sourceCode = R"( + contract test { + function f() { + for (var i = 0; i < msg.data.length; i++) { } + } + } + )"; + CHECK_WARNING(sourceCode, "type uint8, which can only hold"); +} + BOOST_AUTO_TEST_CASE(enum_member_access) { char const* text = R"( -- cgit