diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index 193ad83bd..0c53732d6 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -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 const& member: _struct.members()) { diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index e65431d60..474461dad 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -617,7 +617,7 @@ set VariableDeclaration::allowedDataLocations() c else if (isLocalVariable()) { solAssert(typeName(), ""); - auto getDataLocations = [](TypePointer _type, auto&& _recursion) -> set { + auto dataLocations = [](TypePointer _type, auto&& _recursion) -> set { solAssert(_type, "Can only be called after reference resolution"); switch (_type->category()) { @@ -630,7 +630,7 @@ set VariableDeclaration::allowedDataLocations() c return set{ Location::Memory, Location::Storage }; } }; - return getDataLocations(typeName()->annotation().type, getDataLocations); + return dataLocations(typeName()->annotation().type, dataLocations); } else // Struct members etc. diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 126a40b43..230f18e5e 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -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 recursive; }; diff --git a/test/libsolidity/syntaxTests/array/length/not_too_large.sol b/test/libsolidity/syntaxTests/iceRegressionTests/large_struct_array.sol similarity index 100% rename from test/libsolidity/syntaxTests/array/length/not_too_large.sol rename to test/libsolidity/syntaxTests/iceRegressionTests/large_struct_array.sol diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol index db0ff4af6..027db9754 100644 --- a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol @@ -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.