mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallows fixed-size multidim. arrays with zero-length.
This commit is contained in:
parent
5f919d02ab
commit
ff5be17990
@ -822,12 +822,17 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
||||
{
|
||||
case Type::Category::Array:
|
||||
if (auto arrayType = dynamic_cast<ArrayType const*>(varType.get()))
|
||||
{
|
||||
if (
|
||||
((arrayType->location() == DataLocation::Memory) ||
|
||||
(arrayType->location() == DataLocation::CallData)) &&
|
||||
!arrayType->validForCalldata()
|
||||
)
|
||||
m_errorReporter.typeError(_variable.location(), "Array is too large to be encoded.");
|
||||
if (auto baseType = dynamic_cast<ArrayType const*>(arrayType->baseType().get()))
|
||||
if (!baseType->isDynamicallySized() && baseType->length() == 0)
|
||||
m_errorReporter.typeError(_variable.location(), "Fixed-size multidimensional arrays are not allowed to have zero length.");
|
||||
}
|
||||
break;
|
||||
case Type::Category::Mapping:
|
||||
if (auto mappingType = dynamic_cast<MappingType const*>(varType.get()))
|
||||
|
@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
bytes[0] a;
|
||||
function f() public pure returns(bytes32[0][500] memory) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (62-84): Fixed-size multidimensional arrays are not allowed to have zero length.
|
Loading…
Reference in New Issue
Block a user