mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Removes unnecessary check of array type.
This commit is contained in:
parent
e6d87e54c8
commit
466e8f56e6
@ -241,14 +241,12 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
|
|||||||
if (Expression const* length = _typeName.length())
|
if (Expression const* length = _typeName.length())
|
||||||
{
|
{
|
||||||
TypePointer lengthTypeGeneric = length->annotation().type;
|
TypePointer lengthTypeGeneric = length->annotation().type;
|
||||||
auto arrayType = dynamic_cast<ArrayType const*>(baseType.get());
|
|
||||||
bool isByteOrFixedSizeArray = (arrayType && arrayType->isByteArray()) || !baseType->isDynamicallySized();
|
|
||||||
if (!lengthTypeGeneric)
|
if (!lengthTypeGeneric)
|
||||||
lengthTypeGeneric = ConstantEvaluator(m_errorReporter).evaluate(*length);
|
lengthTypeGeneric = ConstantEvaluator(m_errorReporter).evaluate(*length);
|
||||||
RationalNumberType const* lengthType = dynamic_cast<RationalNumberType const*>(lengthTypeGeneric.get());
|
RationalNumberType const* lengthType = dynamic_cast<RationalNumberType const*>(lengthTypeGeneric.get());
|
||||||
if (!lengthType || !lengthType->mobileType())
|
if (!lengthType || !lengthType->mobileType())
|
||||||
fatalTypeError(length->location(), "Invalid array length, expected integer literal or constant expression.");
|
fatalTypeError(length->location(), "Invalid array length, expected integer literal or constant expression.");
|
||||||
else if (lengthType->isZero() && isByteOrFixedSizeArray)
|
else if (lengthType->isZero())
|
||||||
fatalTypeError(length->location(), "Array with zero length specified.");
|
fatalTypeError(length->location(), "Array with zero length specified.");
|
||||||
else if (lengthType->isFractional())
|
else if (lengthType->isFractional())
|
||||||
fatalTypeError(length->location(), "Array with fractional length specified.");
|
fatalTypeError(length->location(), "Array with fractional length specified.");
|
||||||
|
Loading…
Reference in New Issue
Block a user