aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-03-30 20:34:38 +0800
committerLiana Husikyan <liana@ethdev.com>2015-04-01 21:21:17 +0800
commit06dea23331698800c07c3e4a7645ad8cfbb7d11c (patch)
treeaf43ccf8dd79648df0cf446697ea1604fb877cf2 /AST.cpp
parent37a0234c4a673f130f28a3241cb72589b0aa1f47 (diff)
downloaddexon-solidity-06dea23331698800c07c3e4a7645ad8cfbb7d11c.tar.gz
dexon-solidity-06dea23331698800c07c3e4a7645ad8cfbb7d11c.tar.zst
dexon-solidity-06dea23331698800c07c3e4a7645ad8cfbb7d11c.zip
changed checking for external type in VariableDeclaration::checkTypeRequirements()
changed error msg
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/AST.cpp b/AST.cpp
index 7fe3a982..a111a6f8 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -338,7 +338,14 @@ void FunctionDefinition::checkTypeRequirements()
if (!var->getType()->canLiveOutsideStorage())
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
if (getVisibility() >= Visibility::Public && !(var->getType()->externalType()))
- BOOST_THROW_EXCEPTION(var->createTypeError("Internal type is not allowed for function with external visibility"));
+ {
+ // 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)
+ 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."));
+ }
}
for (ASTPointer<ModifierInvocation> const& modifier: m_functionModifiers)
modifier->checkTypeRequirements(isConstructor() ?
@@ -379,6 +386,14 @@ void VariableDeclaration::checkTypeRequirements()
m_value->expectType(*m_type);
if (m_isStateVariable && !m_type->externalType() && getVisibility() >= Visibility::Public)
BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for state variables."));
+
+ 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
{
// no type declared and no previous assignment, infer the type