mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
miner changes in the implementation of the externalTypes function of FunctionType.
better error messages for exeptions style fixes after review
This commit is contained in:
parent
06dea23331
commit
d7d5b8200a
18
AST.cpp
18
AST.cpp
@ -339,12 +339,11 @@ void FunctionDefinition::checkTypeRequirements()
|
|||||||
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
|
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
|
||||||
if (getVisibility() >= Visibility::Public && !(var->getType()->externalType()))
|
if (getVisibility() >= Visibility::Public && !(var->getType()->externalType()))
|
||||||
{
|
{
|
||||||
// todo delete when arrays as parameter type in internal functions will be implemented
|
// todo delete when will be implemented arrays as parameter type in internal functions
|
||||||
ArrayType const* type = dynamic_cast<ArrayType const*>(var->getType().get());
|
if (getVisibility() == Visibility::Public && var->getType()->getCategory() == Type::Category::Array)
|
||||||
if (getVisibility() == Visibility::Public && type)
|
|
||||||
BOOST_THROW_EXCEPTION(var->createTypeError("Array type is not allowed as parameter for internal functions."));
|
BOOST_THROW_EXCEPTION(var->createTypeError("Array type is not allowed as parameter for internal functions."));
|
||||||
else
|
else
|
||||||
BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed for function with external visibility."));
|
BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed for public and external functions."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ASTPointer<ModifierInvocation> const& modifier: m_functionModifiers)
|
for (ASTPointer<ModifierInvocation> const& modifier: m_functionModifiers)
|
||||||
@ -389,12 +388,11 @@ void VariableDeclaration::checkTypeRequirements()
|
|||||||
|
|
||||||
auto sharedToExternalTypes = FunctionType(*this).externalType(); // do not distroy the shared pointer.
|
auto sharedToExternalTypes = FunctionType(*this).externalType(); // do not distroy the shared pointer.
|
||||||
auto externalFunctionTypes = dynamic_cast<FunctionType const*>(sharedToExternalTypes.get());
|
auto externalFunctionTypes = dynamic_cast<FunctionType const*>(sharedToExternalTypes.get());
|
||||||
TypePointers retParamTypes = externalFunctionTypes->getReturnParameterTypes();
|
for (auto parameter: externalFunctionTypes->getParameterTypes() + externalFunctionTypes->getReturnParameterTypes())
|
||||||
TypePointers parameterTypes = externalFunctionTypes->getParameterTypes();
|
if (!parameter || !(parameter->externalType()))
|
||||||
for (auto parameter: parameterTypes + retParamTypes)
|
BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for public state variables."));
|
||||||
if (!parameter && !(parameter->externalType()))
|
}
|
||||||
BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for state variables."));
|
else
|
||||||
} else
|
|
||||||
{
|
{
|
||||||
// no type declared and no previous assignment, infer the type
|
// no type declared and no previous assignment, infer the type
|
||||||
m_value->checkTypeRequirements();
|
m_value->checkTypeRequirements();
|
||||||
|
10
Types.cpp
10
Types.cpp
@ -1105,13 +1105,15 @@ TypePointer FunctionType::externalType() const
|
|||||||
|
|
||||||
for (auto type: m_parameterTypes)
|
for (auto type: m_parameterTypes)
|
||||||
{
|
{
|
||||||
solAssert(!!type->externalType(), "To be included in external type of the function, the argument should have external type.");
|
if(!type->externalType())
|
||||||
|
return TypePointer();
|
||||||
paramTypes.push_back(type->externalType());
|
paramTypes.push_back(type->externalType());
|
||||||
}
|
}
|
||||||
for(auto param: m_returnParameterTypes)
|
for (auto type: m_returnParameterTypes)
|
||||||
{
|
{
|
||||||
solAssert(!!param->externalType(), "To be included in external type of the function, the argument should have external type.");
|
if(!type->externalType())
|
||||||
retParamTypes.push_back(param->externalType());
|
return TypePointer();
|
||||||
|
retParamTypes.push_back(type->externalType());
|
||||||
}
|
}
|
||||||
return make_shared<FunctionType>(paramTypes, retParamTypes, m_location, m_arbitraryParameters);
|
return make_shared<FunctionType>(paramTypes, retParamTypes, m_location, m_arbitraryParameters);
|
||||||
}
|
}
|
||||||
|
2
Types.h
2
Types.h
@ -512,6 +512,8 @@ public:
|
|||||||
|
|
||||||
virtual Category getCategory() const override { return Category::Function; }
|
virtual Category getCategory() const override { return Category::Function; }
|
||||||
|
|
||||||
|
/// @returns TypePointer of a new FunctionType object. All input/return parameters are an appropriate external types of input/return parameters of current function.
|
||||||
|
/// Returns an empty shared pointer if one of input/return parameters does not have an externaltype.
|
||||||
virtual TypePointer externalType() const override;
|
virtual TypePointer externalType() const override;
|
||||||
|
|
||||||
explicit FunctionType(FunctionDefinition const& _function, bool _isInternal = true);
|
explicit FunctionType(FunctionDefinition const& _function, bool _isInternal = true);
|
||||||
|
Loading…
Reference in New Issue
Block a user