Browse Source

Merge pull request #963 from guanqun/disallow-void-var

Disallow implicit declaration of void type.
cl-refactor
chriseth 10 years ago
parent
commit
732ca849d6
  1. 2
      libsolidity/AST.cpp
  2. 6
      test/SolidityNameAndTypeResolution.cpp

2
libsolidity/AST.cpp

@ -383,6 +383,8 @@ void VariableDefinition::checkTypeRequirements()
BOOST_THROW_EXCEPTION(m_value->createTypeError("Invalid integer constant " + type->toString())); BOOST_THROW_EXCEPTION(m_value->createTypeError("Invalid integer constant " + type->toString()));
type = intType; type = intType;
} }
else if (type->getCategory() == Type::Category::VOID)
BOOST_THROW_EXCEPTION(m_variable->createTypeError("var cannot be void type"));
m_variable->setType(type); m_variable->setType(type);
} }
} }

6
test/SolidityNameAndTypeResolution.cpp

@ -904,6 +904,12 @@ BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args)
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
} }
BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type)
{
char const* sourceCode = "contract c { function f() { var x = f(); } }";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

Loading…
Cancel
Save