mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix ICE when a constant variable declaration forward references a struct
This commit is contained in:
@@ -437,16 +437,14 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
|
||||
type = TypeProvider::withLocation(ref, typeLoc, isPointer);
|
||||
}
|
||||
|
||||
if (
|
||||
_variable.isConstant() &&
|
||||
!dynamic_cast<UserDefinedValueType const*>(type) &&
|
||||
type->containsNestedMapping()
|
||||
)
|
||||
m_errorReporter.fatalDeclarationError(
|
||||
3530_error,
|
||||
_variable.location(),
|
||||
"The type contains a (nested) mapping and therefore cannot be a constant."
|
||||
);
|
||||
if (_variable.isConstant() && !type->isValueType())
|
||||
{
|
||||
bool allowed = false;
|
||||
if (auto arrayType = dynamic_cast<ArrayType const*>(type))
|
||||
allowed = arrayType->isByteArray();
|
||||
if (!allowed)
|
||||
m_errorReporter.fatalTypeError(9259_error, _variable.location(), "Only constants of value type and byte array type are implemented.");
|
||||
}
|
||||
|
||||
_variable.annotation().type = type;
|
||||
}
|
||||
|
||||
@@ -530,15 +530,6 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
||||
}
|
||||
if (_variable.isConstant())
|
||||
{
|
||||
if (!varType->isValueType())
|
||||
{
|
||||
bool allowed = false;
|
||||
if (auto arrayType = dynamic_cast<ArrayType const*>(varType))
|
||||
allowed = arrayType->isByteArray();
|
||||
if (!allowed)
|
||||
m_errorReporter.fatalTypeError(9259_error, _variable.location(), "Constants of non-value type not yet implemented.");
|
||||
}
|
||||
|
||||
if (!_variable.value())
|
||||
m_errorReporter.typeError(4266_error, _variable.location(), "Uninitialized \"constant\" variable.");
|
||||
else if (!*_variable.value()->annotation().isPure)
|
||||
|
||||
@@ -1110,11 +1110,7 @@ public:
|
||||
u256 storageSize() const override { return underlyingType().storageSize(); }
|
||||
unsigned storageBytes() const override { return underlyingType().storageBytes(); }
|
||||
|
||||
bool isValueType() const override
|
||||
{
|
||||
solAssert(underlyingType().isValueType(), "");
|
||||
return true;
|
||||
}
|
||||
bool isValueType() const override { return true; }
|
||||
bool nameable() const override
|
||||
{
|
||||
solAssert(underlyingType().nameable(), "");
|
||||
|
||||
Reference in New Issue
Block a user