mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Type Checker for try/catch.
This commit is contained in:
+13
-12
@@ -452,12 +452,9 @@ bool VariableDeclaration::isLocalVariable() const
|
||||
dynamic_cast<ForStatement const*>(s);
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isCallableParameter() const
|
||||
bool VariableDeclaration::isCallableOrCatchParameter() const
|
||||
{
|
||||
// TODO Adjust for catch params.
|
||||
// I think catch params should return true here.
|
||||
// some of the error strings would need to be adjusted.
|
||||
if (isReturnParameter() || dynamic_cast<TryCatchClause const*>(scope()))
|
||||
if (isReturnParameter() || isTryCatchParameter())
|
||||
return true;
|
||||
|
||||
vector<ASTPointer<VariableDeclaration>> const* parameters = nullptr;
|
||||
@@ -476,8 +473,7 @@ bool VariableDeclaration::isCallableParameter() const
|
||||
|
||||
bool VariableDeclaration::isLocalOrReturn() const
|
||||
{
|
||||
// TODO adjust for catch params
|
||||
return isReturnParameter() || (isLocalVariable() && !isCallableParameter());
|
||||
return isReturnParameter() || (isLocalVariable() && !isCallableOrCatchParameter());
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isReturnParameter() const
|
||||
@@ -497,9 +493,14 @@ bool VariableDeclaration::isReturnParameter() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isTryCatchParameter() const
|
||||
{
|
||||
return dynamic_cast<TryCatchClause const*>(scope());
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isExternalCallableParameter() const
|
||||
{
|
||||
if (!isCallableParameter())
|
||||
if (!isCallableOrCatchParameter())
|
||||
return false;
|
||||
|
||||
if (auto const* callable = dynamic_cast<CallableDeclaration const*>(scope()))
|
||||
@@ -511,7 +512,7 @@ bool VariableDeclaration::isExternalCallableParameter() const
|
||||
|
||||
bool VariableDeclaration::isInternalCallableParameter() const
|
||||
{
|
||||
if (!isCallableParameter())
|
||||
if (!isCallableOrCatchParameter())
|
||||
return false;
|
||||
|
||||
if (auto const* funTypeName = dynamic_cast<FunctionTypeName const*>(scope()))
|
||||
@@ -523,7 +524,7 @@ bool VariableDeclaration::isInternalCallableParameter() const
|
||||
|
||||
bool VariableDeclaration::isLibraryFunctionParameter() const
|
||||
{
|
||||
if (!isCallableParameter())
|
||||
if (!isCallableOrCatchParameter())
|
||||
return false;
|
||||
if (auto const* funDef = dynamic_cast<FunctionDefinition const*>(scope()))
|
||||
return dynamic_cast<ContractDefinition const&>(*funDef->scope()).isLibrary();
|
||||
@@ -559,10 +560,10 @@ set<VariableDeclaration::Location> VariableDeclaration::allowedDataLocations() c
|
||||
locations.insert(Location::Storage);
|
||||
return locations;
|
||||
}
|
||||
else if (isCallableParameter())
|
||||
else if (isCallableOrCatchParameter())
|
||||
{
|
||||
set<Location> locations{ Location::Memory };
|
||||
if (isInternalCallableParameter() || isLibraryFunctionParameter())
|
||||
if (isInternalCallableParameter() || isLibraryFunctionParameter() || isTryCatchParameter())
|
||||
locations.insert(Location::Storage);
|
||||
return locations;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user