mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3011 from wadeAlexC/develop
Adds better error message for fractional array size expressions
This commit is contained in:
commit
d41011a0f6
@ -149,8 +149,10 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
|
||||
if (!length->annotation().type)
|
||||
ConstantEvaluator e(*length);
|
||||
auto const* lengthType = dynamic_cast<RationalNumberType const*>(length->annotation().type.get());
|
||||
if (!lengthType || lengthType->isFractional() || !lengthType->mobileType())
|
||||
if (!lengthType || !lengthType->mobileType())
|
||||
fatalTypeError(length->location(), "Invalid array length, expected integer literal.");
|
||||
else if (lengthType->isFractional())
|
||||
fatalTypeError(length->location(), "Array with fractional length specified.");
|
||||
else if (lengthType->isNegative())
|
||||
fatalTypeError(length->location(), "Array with negative length specified.");
|
||||
else
|
||||
@ -347,4 +349,3 @@ void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location,
|
||||
m_errorOccurred = true;
|
||||
m_errorReporter.fatalDeclarationError(_location, _description);
|
||||
}
|
||||
|
||||
|
@ -4354,7 +4354,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_rational)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal");
|
||||
CHECK_ERROR(text, TypeError, "Array with fractional length specified.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_signed_fixed_type)
|
||||
@ -4366,7 +4366,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_signed_fixed_type)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal");
|
||||
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_unsigned_fixed_type)
|
||||
@ -4378,7 +4378,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_unsigned_fixed_type)
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal");
|
||||
CHECK_ERROR(text, TypeError, "Invalid array length, expected integer literal.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(rational_to_bytes_implicit_conversion)
|
||||
|
Loading…
Reference in New Issue
Block a user