mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow uninitialized storage pointers as experimental 0.5.0 feature.
This commit is contained in:
parent
834dac7989
commit
e08a206070
@ -1,6 +1,7 @@
|
|||||||
### 0.4.21 (unreleased)
|
### 0.4.21 (unreleased)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
* Type Checker: Disallow uninitialized storage pointers as experimental 0.5.0 feature.
|
||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -972,7 +972,11 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
|
|||||||
string errorText{"Uninitialized storage pointer."};
|
string errorText{"Uninitialized storage pointer."};
|
||||||
if (varDecl.referenceLocation() == VariableDeclaration::Location::Default)
|
if (varDecl.referenceLocation() == VariableDeclaration::Location::Default)
|
||||||
errorText += " Did you mean '<type> memory " + varDecl.name() + "'?";
|
errorText += " Did you mean '<type> memory " + varDecl.name() + "'?";
|
||||||
m_errorReporter.warning(varDecl.location(), errorText);
|
solAssert(m_scope, "");
|
||||||
|
if (m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
|
||||||
|
m_errorReporter.declarationError(varDecl.location(), errorText);
|
||||||
|
else
|
||||||
|
m_errorReporter.warning(varDecl.location(), errorText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<MappingType const*>(type(varDecl).get()))
|
else if (dynamic_cast<MappingType const*>(type(varDecl).get()))
|
||||||
|
@ -3021,6 +3021,20 @@ BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable)
|
|||||||
CHECK_WARNING(sourceCode, "Uninitialized storage pointer");
|
CHECK_WARNING(sourceCode, "Uninitialized storage pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable_050)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
pragma experimental "v0.5.0";
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
mapping(uint => uint)[] storage x;
|
||||||
|
x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(sourceCode, DeclarationError, "Uninitialized storage pointer");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers)
|
BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
@ -3320,6 +3334,24 @@ BOOST_AUTO_TEST_CASE(non_initialized_references)
|
|||||||
CHECK_WARNING(text, "Uninitialized storage pointer");
|
CHECK_WARNING(text, "Uninitialized storage pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(non_initialized_references_050)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
pragma experimental "v0.5.0";
|
||||||
|
contract c
|
||||||
|
{
|
||||||
|
struct s {
|
||||||
|
uint a;
|
||||||
|
}
|
||||||
|
function f() public {
|
||||||
|
s storage x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
CHECK_ERROR(text, DeclarationError, "Uninitialized storage pointer");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(keccak256_with_large_integer_constant)
|
BOOST_AUTO_TEST_CASE(keccak256_with_large_integer_constant)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user