aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-17 22:24:23 +0800
committerchriseth <c@ethdev.com>2015-04-17 22:24:23 +0800
commit2d69b269e9da0a8cab7ee4741e8442afa52feecb (patch)
treeb034af03732ed7b56cb9cdd8164d35b53779e520 /AST.cpp
parentc7b428fdb14fac12564d52f25f6101b3e38ace46 (diff)
parent5622364a98102574f04019e2f1041d54d2d04984 (diff)
downloaddexon-solidity-2d69b269e9da0a8cab7ee4741e8442afa52feecb.tar.gz
dexon-solidity-2d69b269e9da0a8cab7ee4741e8442afa52feecb.tar.zst
dexon-solidity-2d69b269e9da0a8cab7ee4741e8442afa52feecb.zip
Merge remote-tracking branch 'ethereum/develop' into sol_overloadingFunctions
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/AST.cpp b/AST.cpp
index 1c1983d9..acf39934 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -451,20 +451,16 @@ void VariableDeclaration::checkTypeRequirements()
if ((m_type && !m_type->isValueType()) || !m_value)
BOOST_THROW_EXCEPTION(createTypeError("Unitialized \"constant\" variable."));
}
- if (!m_value)
- return;
if (m_type)
{
- 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."));
-
- if (!FunctionType(*this).externalType())
- BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for public state variables."));
+ if (m_value)
+ m_value->expectType(*m_type);
}
else
{
- // no type declared and no previous assignment, infer the type
+ if (!m_value)
+ // This feature might be extended in the future.
+ BOOST_THROW_EXCEPTION(createTypeError("Assignment necessary for type detection."));
m_value->checkTypeRequirements(nullptr);
TypePointer type = m_value->getType();
@@ -479,6 +475,8 @@ void VariableDeclaration::checkTypeRequirements()
BOOST_THROW_EXCEPTION(createTypeError("Variable cannot have void type."));
m_type = type;
}
+ if (m_isStateVariable && getVisibility() >= Visibility::Public && !FunctionType(*this).externalType())
+ BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for public state variables."));
}
bool VariableDeclaration::isExternalFunctionParameter() const