aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-27 03:27:53 +0800
committerchriseth <c@ethdev.com>2015-06-27 03:28:02 +0800
commitfac812441215f4721f5e0a2b3d79d358a085a101 (patch)
tree4315a81c2e3479724cf7287572f84d2e0ea9719c
parent03edf74e62f8dde537c8d3f956c6cc0a5e823e6b (diff)
downloaddexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.tar
dexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.tar.gz
dexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.tar.bz2
dexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.tar.lz
dexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.tar.xz
dexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.tar.zst
dexon-solidity-fac812441215f4721f5e0a2b3d79d358a085a101.zip
Disallow memory types containing mappings.
-rw-r--r--AST.cpp11
-rw-r--r--Types.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/AST.cpp b/AST.cpp
index 09af49c6..2b73aab5 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -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."));
}
diff --git a/Types.h b/Types.h
index d15e2f96..6b03b1ae 100644
--- a/Types.h
+++ b/Types.h
@@ -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