Review suggestions.

This commit is contained in:
Daniel Kirchner 2020-04-15 16:00:01 +02:00
parent 3a5a4c6505
commit 6093982606
5 changed files with 9 additions and 5 deletions

View File

@ -102,7 +102,7 @@ bool DeclarationTypeChecker::visit(StructDefinition const& _struct)
auto visitor = [&](StructDefinition const& _struct, auto& _cycleDetector, size_t _depth)
{
if (_depth >= 256)
fatalDeclarationError(_struct.location(), "Struct definition exhausting cyclic dependency validator.");
fatalDeclarationError(_struct.location(), "Struct definition exhausts cyclic dependency validator.");
for (ASTPointer<VariableDeclaration> const& member: _struct.members())
{

View File

@ -617,7 +617,7 @@ set<VariableDeclaration::Location> VariableDeclaration::allowedDataLocations() c
else if (isLocalVariable())
{
solAssert(typeName(), "");
auto getDataLocations = [](TypePointer _type, auto&& _recursion) -> set<Location> {
auto dataLocations = [](TypePointer _type, auto&& _recursion) -> set<Location> {
solAssert(_type, "Can only be called after reference resolution");
switch (_type->category())
{
@ -630,7 +630,7 @@ set<VariableDeclaration::Location> VariableDeclaration::allowedDataLocations() c
return set<Location>{ Location::Memory, Location::Storage };
}
};
return getDataLocations(typeName()->annotation().type, getDataLocations);
return dataLocations(typeName()->annotation().type, dataLocations);
}
else
// Struct members etc.

View File

@ -130,7 +130,11 @@ struct TypeDeclarationAnnotation: DeclarationAnnotation
struct StructDeclarationAnnotation: TypeDeclarationAnnotation
{
/// Whether the struct is recursive. Will be filled in by the DeclarationTypeChecker.
/// Whether the struct is recursive, i.e. if the struct (recursively) contains a member that involves a struct of the same
/// type, either in a dynamic array, as member of another struct or inside a mapping.
/// Only cases in which the recursive occurrence is within a dynamic array or a mapping are valid, while direct
/// recursion immediately raises an error.
/// Will be filled in by the DeclarationTypeChecker.
std::optional<bool> recursive;
};

View File

@ -257,4 +257,4 @@ contract Main {
struct JW { int i; }
}
// ----
// DeclarationError: (6091-6111): Struct definition exhausting cyclic dependency validator.
// DeclarationError: (6091-6111): Struct definition exhausts cyclic dependency validator.