Disallow memory types containing mappings.

This commit is contained in:
chriseth 2015-06-26 21:27:53 +02:00
parent 03edf74e62
commit fac8124412
2 changed files with 11 additions and 1 deletions

11
AST.cpp
View File

@ -535,7 +535,16 @@ void VariableDeclaration::checkTypeRequirements()
BOOST_THROW_EXCEPTION(createTypeError("Variable cannot have void type."));
m_type = type->mobileType();
}
if (m_isStateVariable && getVisibility() >= Visibility::Public && !FunctionType(*this).externalType())
solAssert(!!m_type, "");
if (!m_isStateVariable)
{
if (m_type->dataStoredIn(DataLocation::Memory) || m_type->dataStoredIn(DataLocation::CallData))
if (!m_type->canLiveOutsideStorage())
BOOST_THROW_EXCEPTION(createTypeError(
"Type " + m_type->toString() + " is only valid in storage."
));
}
else if (getVisibility() >= Visibility::Public && !FunctionType(*this).externalType())
BOOST_THROW_EXCEPTION(createTypeError("Internal type is not allowed for public state variables."));
}

View File

@ -449,6 +449,7 @@ public:
virtual unsigned getCalldataEncodedSize(bool _padded) const override;
virtual bool isDynamicallySized() const override { return m_hasDynamicLength; }
virtual u256 getStorageSize() const override;
virtual bool canLiveOutsideStorage() const override { return m_baseType->canLiveOutsideStorage(); }
virtual unsigned getSizeOnStack() const override;
virtual std::string toString(bool _short) const override;
virtual MemberList const& getMembers() const override