mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3014 from ethereum/require-storage-keyword
Require location keyword for local variables (0.5.0)
This commit is contained in:
commit
b8e904616a
@ -9,6 +9,7 @@ Features:
|
||||
* Syntax Checker: Unary ``+`` is now a syntax error as experimental 0.5.0 feature.
|
||||
* Type Checker: Disallow non-pure constant state variables as experimental 0.5.0 feature.
|
||||
* Type Checker: Do not add members of ``address`` to contracts as experimental 0.5.0 feature.
|
||||
* Type Checker: Require ``storage`` or ``memory`` keyword for local variables as experimental 0.5.0 feature.
|
||||
|
||||
Bugfixes:
|
||||
* Parser: Fix source location of VariableDeclarationStatement.
|
||||
|
@ -298,11 +298,19 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
|
||||
{
|
||||
typeLoc = DataLocation::Storage;
|
||||
if (_variable.isLocalVariable())
|
||||
m_errorReporter.warning(
|
||||
_variable.location(),
|
||||
"Variable is declared as a storage pointer. "
|
||||
"Use an explicit \"storage\" keyword to silence this warning."
|
||||
);
|
||||
{
|
||||
if (_variable.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050))
|
||||
typeError(
|
||||
_variable.location(),
|
||||
"Storage location must be specified as either \"memory\" or \"storage\"."
|
||||
);
|
||||
else
|
||||
m_errorReporter.warning(
|
||||
_variable.location(),
|
||||
"Variable is declared as a storage pointer. "
|
||||
"Use an explicit \"storage\" keyword to silence this warning."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -6523,7 +6523,19 @@ BOOST_AUTO_TEST_CASE(warn_unspecified_storage)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "is declared as a storage pointer. Use an explicit \"storage\" keyword to silence this warning");
|
||||
CHECK_WARNING(text, "Variable is declared as a storage pointer. Use an explicit \"storage\" keyword to silence this warning");
|
||||
text = R"(
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
struct S { uint a; }
|
||||
S x;
|
||||
function f() view public {
|
||||
S y = x;
|
||||
y;
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Storage location must be specified as either \"memory\" or \"storage\".");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(implicit_conversion_disallowed)
|
||||
|
Loading…
Reference in New Issue
Block a user