aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-04-01 21:19:33 +0800
committerLiana Husikyan <liana@ethdev.com>2015-04-01 21:21:17 +0800
commitd7d5b8200a617e5faa3a3d7510aa408ff73e3237 (patch)
tree9c8ff54cfecd5eb284473488ac4da02620bf85fd /AST.cpp
parent06dea23331698800c07c3e4a7645ad8cfbb7d11c (diff)
downloaddexon-solidity-d7d5b8200a617e5faa3a3d7510aa408ff73e3237.tar.gz
dexon-solidity-d7d5b8200a617e5faa3a3d7510aa408ff73e3237.tar.zst
dexon-solidity-d7d5b8200a617e5faa3a3d7510aa408ff73e3237.zip
miner changes in the implementation of the externalTypes function of FunctionType.
better error messages for exeptions style fixes after review
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/AST.cpp b/AST.cpp
index a111a6f8..d489a448 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -339,12 +339,11 @@ void FunctionDefinition::checkTypeRequirements()
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
if (getVisibility() >= Visibility::Public && !(var->getType()->externalType()))
{
- // todo delete when arrays as parameter type in internal functions will be implemented
- ArrayType const* type = dynamic_cast<ArrayType const*>(var->getType().get());
- if (getVisibility() == Visibility::Public && type)
+ // todo delete when will be implemented arrays as parameter type in internal functions
+ if (getVisibility() == Visibility::Public && var->getType()->getCategory() == Type::Category::Array)
BOOST_THROW_EXCEPTION(var->createTypeError("Array type is not allowed as parameter for internal functions."));
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)
@@ -389,12 +388,11 @@ void VariableDeclaration::checkTypeRequirements()
auto sharedToExternalTypes = FunctionType(*this).externalType(); // do not distroy the shared pointer.
auto externalFunctionTypes = dynamic_cast<FunctionType const*>(sharedToExternalTypes.get());
- TypePointers retParamTypes = externalFunctionTypes->getReturnParameterTypes();
- TypePointers parameterTypes = externalFunctionTypes->getParameterTypes();
- for (auto parameter: parameterTypes + retParamTypes)
- if (!parameter && !(parameter->externalType()))
- BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for state variables."));
- } else
+ for (auto parameter: externalFunctionTypes->getParameterTypes() + externalFunctionTypes->getReturnParameterTypes())
+ if (!parameter || !(parameter->externalType()))
+ BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for public state variables."));
+ }
+ else
{
// no type declared and no previous assignment, infer the type
m_value->checkTypeRequirements();