diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 31129feab..a4b92bcec 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -642,6 +642,11 @@ bool VariableDeclaration::hasReferenceOrMappingType() const return type->category() == Type::Category::Mapping || dynamic_cast(type); } +bool VariableDeclaration::isStateVariable() const +{ + return dynamic_cast(scope()); +} + set VariableDeclaration::allowedDataLocations() const { using Location = VariableDeclaration::Location; diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 7a986225d..fa339b53e 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -905,7 +905,6 @@ public: ASTPointer _value, Visibility _visibility, ASTPointer const _documentation = nullptr, - bool _isStateVar = false, bool _isIndexed = false, Mutability _mutability = Mutability::Mutable, ASTPointer _overrides = nullptr, @@ -915,7 +914,6 @@ public: StructurallyDocumented(std::move(_documentation)), m_typeName(std::move(_type)), m_value(std::move(_value)), - m_isStateVariable(_isStateVar), m_isIndexed(_isIndexed), m_mutability(_mutability), m_overrides(std::move(_overrides)), @@ -962,7 +960,7 @@ public: /// array, struct or mapping. These types can take a data location (and often require it). /// Can only be called after reference resolution. bool hasReferenceOrMappingType() const; - bool isStateVariable() const { return m_isStateVariable; } + bool isStateVariable() const; bool isIndexed() const { return m_isIndexed; } Mutability mutability() const { return m_mutability; } bool isConstant() const { return m_mutability == Mutability::Constant; } @@ -991,7 +989,6 @@ private: /// Initially assigned value, can be missing. For local variables, this is stored inside /// VariableDeclarationStatement and not here. ASTPointer m_value; - bool m_isStateVariable = false; ///< Whether or not this is a contract state variable bool m_isIndexed = false; ///< Whether this is an indexed variable (used by events). /// Whether the variable is "constant", "immutable" or non-marked (mutable). Mutability m_mutability = Mutability::Mutable; diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index 5e44b8616..48eed4d8a 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -454,7 +454,6 @@ ASTPointer ASTJsonImporter::createVariableDeclaration(Json: nullOrCast(member(_node, "value")), visibility(_node), _node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")), - memberAsBool(_node, "stateVariable"), _node.isMember("indexed") ? memberAsBool(_node, "indexed") : false, mutability, _node["overrides"].isNull() ? nullptr : createOverrideSpecifier(member(_node, "overrides")), diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 77492ef2d..1a3ff7875 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -800,7 +800,6 @@ ASTPointer Parser::parseVariableDeclaration( value, visibility, documentation, - _options.isStateVariable, isIndexed, mutability, overrides,