mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Removed redundant declaration check; changed relevant test cases
This commit is contained in:
parent
1587486334
commit
79387b2ada
@ -1061,17 +1061,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
|
||||
if (!varDecl.annotation().type)
|
||||
m_errorReporter.fatalTypeError(_statement.location(), "Use of the \"var\" keyword is disallowed.");
|
||||
|
||||
if (auto ref = dynamic_cast<ReferenceType const*>(type(varDecl)))
|
||||
{
|
||||
if (ref->dataStoredIn(DataLocation::Storage))
|
||||
{
|
||||
string errorText{"Uninitialized storage pointer."};
|
||||
solAssert(varDecl.referenceLocation() != VariableDeclaration::Location::Unspecified, "Expected a specified location at this point");
|
||||
solAssert(m_scope, "");
|
||||
m_errorReporter.declarationError(varDecl.location(), errorText);
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<MappingType const*>(type(varDecl)))
|
||||
if (dynamic_cast<MappingType const*>(type(varDecl)))
|
||||
m_errorReporter.typeError(
|
||||
varDecl.location(),
|
||||
"Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable."
|
||||
|
@ -2,8 +2,10 @@ contract C {
|
||||
function f() public {
|
||||
uint[] storage x;
|
||||
uint[10] storage y;
|
||||
x;
|
||||
y;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (38-54): Uninitialized storage pointer.
|
||||
// DeclarationError: (58-76): Uninitialized storage pointer.
|
||||
// TypeError: (80-81): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
|
||||
// TypeError: (85-86): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
|
||||
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (52-85): Uninitialized storage pointer.
|
||||
// TypeError: (95-96): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
|
||||
|
@ -8,4 +8,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (84-95): Uninitialized storage pointer.
|
||||
// TypeError: (105-106): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
|
||||
|
@ -3,4 +3,3 @@ contract c {
|
||||
}
|
||||
// ----
|
||||
// TypeError: (39-58): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer.
|
||||
// DeclarationError: (60-83): Uninitialized storage pointer.
|
||||
|
Loading…
Reference in New Issue
Block a user