aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-02-27 21:50:06 +0800
committerChristian <c@ethdev.com>2015-02-28 05:52:19 +0800
commit2ea8f3a75a9eaf6006052426168cb70ef5c6fa8d (patch)
treec65235ecd2b8b17786c674db6c1621656f979fb8 /Types.cpp
parent87365f7612336c4c7f443aac568f8a515bc9bd35 (diff)
downloaddexon-solidity-2ea8f3a75a9eaf6006052426168cb70ef5c6fa8d.tar.gz
dexon-solidity-2ea8f3a75a9eaf6006052426168cb70ef5c6fa8d.tar.zst
dexon-solidity-2ea8f3a75a9eaf6006052426168cb70ef5c6fa8d.zip
Type checks for array assignment.
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/Types.cpp b/Types.cpp
index adcd2e54..8cc1f258 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -537,7 +537,19 @@ TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const
bool ArrayType::isImplicitlyConvertibleTo(const Type& _convertTo) const
{
- return _convertTo.getCategory() == getCategory();
+ if (_convertTo.getCategory() != getCategory())
+ return false;
+ auto& convertTo = dynamic_cast<ArrayType const&>(_convertTo);
+ // let us not allow assignment to memory arrays for now
+ if (convertTo.getLocation() != Location::Storage)
+ return false;
+ if (convertTo.isByteArray() != isByteArray())
+ return false;
+ if (!getBaseType()->isImplicitlyConvertibleTo(*convertTo.getBaseType()))
+ return false;
+ if (convertTo.isDynamicallySized())
+ return true;
+ return !isDynamicallySized() && convertTo.getLength() >= getLength();
}
TypePointer ArrayType::unaryOperatorResult(Token::Value _operator) const
@@ -552,7 +564,10 @@ bool ArrayType::operator==(Type const& _other) const
if (_other.getCategory() != getCategory())
return false;
ArrayType const& other = dynamic_cast<ArrayType const&>(_other);
- return other.m_location == m_location;
+ if (other.m_location != m_location || other.isByteArray() != isByteArray() ||
+ other.isDynamicallySized() != isDynamicallySized())
+ return false;
+ return isDynamicallySized() || getLength() == other.getLength();
}
u256 ArrayType::getStorageSize() const