diff options
author | Liana Husikyan <liana@ethdev.com> | 2015-03-14 01:16:04 +0800 |
---|---|---|
committer | Liana Husikyan <liana@ethdev.com> | 2015-03-16 17:46:46 +0800 |
commit | ebb4d5e298cbe9d8d6bb6b1fa1d8f6f769d62fba (patch) | |
tree | 81ba1220fa9c3b57c792cb87806278ff3af51815 /AST.cpp | |
parent | 7d6357ae531f604387fc1f91799fca9a9102e856 (diff) | |
download | dexon-solidity-ebb4d5e298cbe9d8d6bb6b1fa1d8f6f769d62fba.tar.gz dexon-solidity-ebb4d5e298cbe9d8d6bb6b1fa1d8f6f769d62fba.tar.zst dexon-solidity-ebb4d5e298cbe9d8d6bb6b1fa1d8f6f769d62fba.zip |
- added more tests to check constant specifier implementation
- deny use of const for local variables
- deny unitialized const variables
- only int, fixed strings, and enums can be declaired as const
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -332,6 +332,13 @@ void VariableDeclaration::checkTypeRequirements() // sets the type. // Note that assignments before the first declaration are legal because of the special scoping // rules inherited from JavaScript. + if (m_isConstant) + { + if (!dynamic_cast<ContractDefinition const*>(getScope())) + BOOST_THROW_EXCEPTION(createTypeError("Illegal use of \"constant\" specifier.")); + if ((m_type && !m_type->isValueType()) || !m_value) + BOOST_THROW_EXCEPTION(createTypeError("Unitialized \"constant\" variable.")); + } if (!m_value) return; if (m_type) |