From 24716404f8d9f714f43a3bea51f46f2fc5ccf769 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 13 Aug 2019 13:00:46 +0200 Subject: [PATCH] Parse override keyword --- liblangutil/Token.h | 2 +- libsolidity/ast/AST.h | 34 ++ libsolidity/ast/ASTForward.h | 1 + libsolidity/ast/ASTJsonConverter.cpp | 2 + libsolidity/ast/ASTPrinter.cpp | 12 + libsolidity/ast/ASTPrinter.h | 2 + libsolidity/ast/ASTVisitor.h | 4 + libsolidity/ast/AST_accept.h | 18 + libsolidity/parsing/Parser.cpp | 55 +- libsolidity/parsing/Parser.h | 4 +- .../standard_only_ast_requested/output.json | 2 +- test/libsolidity/ASTJSON/address_payable.json | 6 + .../ASTJSON/address_payable_legacy.json | 6 + test/libsolidity/ASTJSON/array_type_name.json | 1 + test/libsolidity/ASTJSON/array_type_name.sol | 2 + .../ASTJSON/array_type_name_legacy.json | 1 + test/libsolidity/ASTJSON/constructor.json | 1 + test/libsolidity/ASTJSON/constructor.sol | 2 + .../ASTJSON/constructor_legacy.json | 1 + test/libsolidity/ASTJSON/documentation.json | 1 + test/libsolidity/ASTJSON/documentation.sol | 2 + .../ASTJSON/documentation_legacy.json | 1 + test/libsolidity/ASTJSON/fallback.json | 1 + test/libsolidity/ASTJSON/fallback.sol | 2 + test/libsolidity/ASTJSON/fallback_legacy.json | 1 + .../libsolidity/ASTJSON/fallback_payable.json | 1 + test/libsolidity/ASTJSON/fallback_payable.sol | 2 + .../ASTJSON/fallback_payable_legacy.json | 1 + test/libsolidity/ASTJSON/function_type.json | 5 + .../ASTJSON/function_type_legacy.json | 5 + .../long_type_name_binary_operation.json | 2 + .../long_type_name_binary_operation.sol | 2 + ...ong_type_name_binary_operation_legacy.json | 2 + .../ASTJSON/long_type_name_identifier.json | 3 + .../ASTJSON/long_type_name_identifier.sol | 2 + .../long_type_name_identifier_legacy.json | 3 + .../ASTJSON/modifier_definition.json | 2 + .../ASTJSON/modifier_definition.sol | 2 + .../ASTJSON/modifier_definition_legacy.json | 2 + .../ASTJSON/modifier_invocation.json | 2 + .../ASTJSON/modifier_invocation.sol | 2 + .../ASTJSON/modifier_invocation_legacy.json | 2 + test/libsolidity/ASTJSON/non_utf8.json | 2 + test/libsolidity/ASTJSON/non_utf8.sol | 2 + test/libsolidity/ASTJSON/non_utf8_legacy.json | 2 + test/libsolidity/ASTJSON/override.json | 337 ++++++++++++ test/libsolidity/ASTJSON/override.sol | 13 + test/libsolidity/ASTJSON/override_legacy.json | 492 ++++++++++++++++++ test/libsolidity/ASTJSON/short_type_name.json | 2 + test/libsolidity/ASTJSON/short_type_name.sol | 2 + .../ASTJSON/short_type_name_legacy.json | 2 + .../ASTJSON/short_type_name_ref.json | 2 + .../ASTJSON/short_type_name_ref.sol | 2 + .../ASTJSON/short_type_name_ref_legacy.json | 2 + test/libsolidity/ASTJSON/source_location.json | 2 + test/libsolidity/ASTJSON/source_location.sol | 2 + .../ASTJSON/source_location_legacy.json | 2 + test/libsolidity/SolidityParser.cpp | 1 - .../override/detect_double_override.sol | 7 + .../inheritance/override/override.sol | 5 + .../override/override_empty_list.sol | 10 + .../override/override_multiple.sol | 9 + .../override/override_multiple_fail1.sol | 8 + .../override/override_multiple_fail2.sol | 8 + .../override/override_multiple_fail3.sol | 8 + .../override/override_multiple_fail4.sol | 8 + 66 files changed, 1127 insertions(+), 7 deletions(-) create mode 100644 test/libsolidity/ASTJSON/override.json create mode 100644 test/libsolidity/ASTJSON/override.sol create mode 100644 test/libsolidity/ASTJSON/override_legacy.json create mode 100644 test/libsolidity/syntaxTests/inheritance/override/detect_double_override.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override_empty_list.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override_multiple.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail1.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail2.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail3.sol create mode 100644 test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail4.sol diff --git a/liblangutil/Token.h b/liblangutil/Token.h index 35d4f76f3..c725c43bd 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -171,6 +171,7 @@ namespace langutil K(Memory, "memory", 0) \ K(Modifier, "modifier", 0) \ K(New, "new", 0) \ + K(Override, "override", 0) \ K(Payable, "payable", 0) \ K(Public, "public", 0) \ K(Pragma, "pragma", 0) \ @@ -248,7 +249,6 @@ namespace langutil K(Mutable, "mutable", 0) \ K(NullLiteral, "null", 0) \ K(Of, "of", 0) \ - K(Override, "override", 0) \ K(Partial, "partial", 0) \ K(Promise, "promise", 0) \ K(Reference, "reference", 0) \ diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index b84ad2c19..764a5d9fe 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -604,6 +604,32 @@ protected: ASTPointer m_returnParameters; }; +/** + * Function override specifier. Consists of a single override keyword + * potentially followed by a parenthesized list of base contract names. + */ +class OverrideSpecifier: public ASTNode +{ +public: + OverrideSpecifier( + SourceLocation const& _location, + std::vector> const& _overrides + ): + ASTNode(_location), + m_overrides(_overrides) + { + } + + void accept(ASTVisitor& _visitor) override; + void accept(ASTConstVisitor& _visitor) const override; + + /// @returns the list of specific overrides, if any + std::vector> const& overrides() const { return m_overrides; } + +protected: + std::vector> m_overrides; +}; + class FunctionDefinition: public CallableDeclaration, public Documented, public ImplementationOptional { public: @@ -613,6 +639,7 @@ public: Declaration::Visibility _visibility, StateMutability _stateMutability, bool _isConstructor, + ASTPointer const& _overrides, ASTPointer const& _documentation, ASTPointer const& _parameters, std::vector> const& _modifiers, @@ -624,6 +651,7 @@ public: ImplementationOptional(_body != nullptr), m_stateMutability(_stateMutability), m_isConstructor(_isConstructor), + m_overrides(_overrides), m_functionModifiers(_modifiers), m_body(_body) {} @@ -633,6 +661,7 @@ public: StateMutability stateMutability() const { return m_stateMutability; } bool isConstructor() const { return m_isConstructor; } + ASTPointer const& overrides() const { return m_overrides; } bool isFallback() const { return !m_isConstructor && name().empty(); } bool isPayable() const { return m_stateMutability == StateMutability::Payable; } std::vector> const& modifiers() const { return m_functionModifiers; } @@ -661,6 +690,7 @@ public: private: StateMutability m_stateMutability; bool m_isConstructor; + ASTPointer m_overrides; std::vector> m_functionModifiers; ASTPointer m_body; }; @@ -683,6 +713,7 @@ public: bool _isStateVar = false, bool _isIndexed = false, bool _isConstant = false, + ASTPointer const& _overrides = nullptr, Location _referenceLocation = Location::Unspecified ): Declaration(_sourceLocation, _name, _visibility), @@ -691,6 +722,7 @@ public: m_isStateVariable(_isStateVar), m_isIndexed(_isIndexed), m_isConstant(_isConstant), + m_overrides(_overrides), m_location(_referenceLocation) {} void accept(ASTVisitor& _visitor) override; @@ -730,6 +762,7 @@ public: bool isStateVariable() const { return m_isStateVariable; } bool isIndexed() const { return m_isIndexed; } bool isConstant() const { return m_isConstant; } + ASTPointer const& overrides() const { return m_overrides; } Location referenceLocation() const { return m_location; } /// @returns a set of allowed storage locations for the variable. std::set allowedDataLocations() const; @@ -753,6 +786,7 @@ private: bool m_isStateVariable; ///< Whether or not this is a contract state variable bool m_isIndexed; ///< Whether this is an indexed variable (used by events). bool m_isConstant; ///< Whether the variable is a compile-time constant. + ASTPointer m_overrides; ///< Contains the override specifier node Location m_location; ///< Location of the variable if it is of reference type. }; diff --git a/libsolidity/ast/ASTForward.h b/libsolidity/ast/ASTForward.h index aad4ad558..db6952694 100644 --- a/libsolidity/ast/ASTForward.h +++ b/libsolidity/ast/ASTForward.h @@ -39,6 +39,7 @@ class PragmaDirective; class ImportDirective; class Declaration; class CallableDeclaration; +class OverrideSpecifier; class ContractDefinition; class InheritanceSpecifier; class UsingForDirective; diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index 669b46d53..a81ec3ac9 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -334,6 +334,7 @@ bool ASTJsonConverter::visit(FunctionDefinition const& _node) make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())), make_pair("superFunction", idOrNull(_node.annotation().superFunction)), make_pair("visibility", Declaration::visibilityToString(_node.visibility())), + make_pair("overrides", _node.overrides() ? toJson(_node.overrides()->overrides()) : Json::nullValue), make_pair("parameters", toJson(_node.parameterList())), make_pair("returnParameters", toJson(*_node.returnParameterList())), make_pair("modifiers", toJson(_node.modifiers())), @@ -355,6 +356,7 @@ bool ASTJsonConverter::visit(VariableDeclaration const& _node) make_pair("constant", _node.isConstant()), make_pair("stateVariable", _node.isStateVariable()), make_pair("storageLocation", location(_node.referenceLocation())), + make_pair("overrides", _node.overrides() ? toJson(_node.overrides()->overrides()) : Json::nullValue), make_pair("visibility", Declaration::visibilityToString(_node.visibility())), make_pair("value", _node.value() ? toJson(*_node.value()) : Json::nullValue), make_pair("scope", idOrNull(_node.scope())), diff --git a/libsolidity/ast/ASTPrinter.cpp b/libsolidity/ast/ASTPrinter.cpp index 7d77ff7b9..1d9f40876 100644 --- a/libsolidity/ast/ASTPrinter.cpp +++ b/libsolidity/ast/ASTPrinter.cpp @@ -111,6 +111,13 @@ bool ASTPrinter::visit(ParameterList const& _node) return goDeeper(); } +bool ASTPrinter::visit(OverrideSpecifier const& _node) +{ + writeLine("OverrideSpecifier"); + printSourcePart(_node); + return goDeeper(); +} + bool ASTPrinter::visit(FunctionDefinition const& _node) { writeLine( @@ -432,6 +439,11 @@ void ASTPrinter::endVisit(ParameterList const&) m_indentation--; } +void ASTPrinter::endVisit(OverrideSpecifier const&) +{ + m_indentation--; +} + void ASTPrinter::endVisit(FunctionDefinition const&) { m_indentation--; diff --git a/libsolidity/ast/ASTPrinter.h b/libsolidity/ast/ASTPrinter.h index 2e9cb4fc6..697db4378 100644 --- a/libsolidity/ast/ASTPrinter.h +++ b/libsolidity/ast/ASTPrinter.h @@ -56,6 +56,7 @@ public: bool visit(EnumDefinition const& _node) override; bool visit(EnumValue const& _node) override; bool visit(ParameterList const& _node) override; + bool visit(OverrideSpecifier const& _node) override; bool visit(FunctionDefinition const& _node) override; bool visit(VariableDeclaration const& _node) override; bool visit(ModifierDefinition const& _node) override; @@ -101,6 +102,7 @@ public: void endVisit(EnumDefinition const&) override; void endVisit(EnumValue const&) override; void endVisit(ParameterList const&) override; + void endVisit(OverrideSpecifier const&) override; void endVisit(FunctionDefinition const&) override; void endVisit(VariableDeclaration const&) override; void endVisit(ModifierDefinition const&) override; diff --git a/libsolidity/ast/ASTVisitor.h b/libsolidity/ast/ASTVisitor.h index 5b97bb06a..6184e5f42 100644 --- a/libsolidity/ast/ASTVisitor.h +++ b/libsolidity/ast/ASTVisitor.h @@ -54,6 +54,7 @@ public: virtual bool visit(EnumDefinition& _node) { return visitNode(_node); } virtual bool visit(EnumValue& _node) { return visitNode(_node); } virtual bool visit(ParameterList& _node) { return visitNode(_node); } + virtual bool visit(OverrideSpecifier& _node) { return visitNode(_node); } virtual bool visit(FunctionDefinition& _node) { return visitNode(_node); } virtual bool visit(VariableDeclaration& _node) { return visitNode(_node); } virtual bool visit(ModifierDefinition& _node) { return visitNode(_node); } @@ -100,6 +101,7 @@ public: virtual void endVisit(EnumDefinition& _node) { endVisitNode(_node); } virtual void endVisit(EnumValue& _node) { endVisitNode(_node); } virtual void endVisit(ParameterList& _node) { endVisitNode(_node); } + virtual void endVisit(OverrideSpecifier& _node) { endVisitNode(_node); } virtual void endVisit(FunctionDefinition& _node) { endVisitNode(_node); } virtual void endVisit(VariableDeclaration& _node) { endVisitNode(_node); } virtual void endVisit(ModifierDefinition& _node) { endVisitNode(_node); } @@ -159,6 +161,7 @@ public: virtual bool visit(EnumDefinition const& _node) { return visitNode(_node); } virtual bool visit(EnumValue const& _node) { return visitNode(_node); } virtual bool visit(ParameterList const& _node) { return visitNode(_node); } + virtual bool visit(OverrideSpecifier const& _node) { return visitNode(_node); } virtual bool visit(FunctionDefinition const& _node) { return visitNode(_node); } virtual bool visit(VariableDeclaration const& _node) { return visitNode(_node); } virtual bool visit(ModifierDefinition const& _node) { return visitNode(_node); } @@ -205,6 +208,7 @@ public: virtual void endVisit(EnumDefinition const& _node) { endVisitNode(_node); } virtual void endVisit(EnumValue const& _node) { endVisitNode(_node); } virtual void endVisit(ParameterList const& _node) { endVisitNode(_node); } + virtual void endVisit(OverrideSpecifier const& _node) { endVisitNode(_node); } virtual void endVisit(FunctionDefinition const& _node) { endVisitNode(_node); } virtual void endVisit(VariableDeclaration const& _node) { endVisitNode(_node); } virtual void endVisit(ModifierDefinition const& _node) { endVisitNode(_node); } diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h index 5538180d9..a95c22d7b 100644 --- a/libsolidity/ast/AST_accept.h +++ b/libsolidity/ast/AST_accept.h @@ -187,10 +187,26 @@ void ParameterList::accept(ASTConstVisitor& _visitor) const _visitor.endVisit(*this); } +void OverrideSpecifier::accept(ASTVisitor& _visitor) +{ + if (_visitor.visit(*this)) + listAccept(m_overrides, _visitor); + _visitor.endVisit(*this); +} + +void OverrideSpecifier::accept(ASTConstVisitor& _visitor) const +{ + if (_visitor.visit(*this)) + listAccept(m_overrides, _visitor); + _visitor.endVisit(*this); +} + void FunctionDefinition::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) { + if (m_overrides) + m_overrides->accept(_visitor); m_parameters->accept(_visitor); if (m_returnParameters) m_returnParameters->accept(_visitor); @@ -205,6 +221,8 @@ void FunctionDefinition::accept(ASTConstVisitor& _visitor) const { if (_visitor.visit(*this)) { + if (m_overrides) + m_overrides->accept(_visitor); m_parameters->accept(_visitor); if (m_returnParameters) m_returnParameters->accept(_visitor); diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 55c73a267..b358e4a94 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -382,6 +382,36 @@ Declaration::Visibility Parser::parseVisibilitySpecifier() return visibility; } +ASTPointer Parser::parseOverrideSpecifier() +{ + solAssert(m_scanner->currentToken() == Token::Override, ""); + + ASTNodeFactory nodeFactory(*this); + std::vector> overrides; + + nodeFactory.markEndPosition(); + m_scanner->next(); + + if (m_scanner->currentToken() == Token::LParen) + { + m_scanner->next(); + while (true) + { + overrides.push_back(parseUserDefinedTypeName()); + + if (m_scanner->currentToken() == Token::RParen) + break; + + expectToken(Token::Comma); + } + + nodeFactory.markEndPosition(); + expectToken(Token::RParen); + } + + return nodeFactory.createNode(move(overrides)); +} + StateMutability Parser::parseStateMutability() { StateMutability stateMutability(StateMutability::NonPayable); @@ -411,12 +441,13 @@ StateMutability Parser::parseStateMutability() return stateMutability; } -Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers) +Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _onlyFuncType, bool _allowFuncDef) { RecursionGuard recursionGuard(*this); FunctionHeaderParserResult result; result.isConstructor = false; + result.overrides = nullptr; if (m_scanner->currentToken() == Token::Constructor) result.isConstructor = true; @@ -426,7 +457,7 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN if (result.isConstructor) result.name = make_shared(); - else if (_forceEmptyName || m_scanner->currentToken() == Token::LParen) + else if (_onlyFuncType || m_scanner->currentToken() == Token::LParen) result.name = make_shared(); else if (m_scanner->currentToken() == Token::Constructor) fatalParserError(string( @@ -443,7 +474,7 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN while (true) { Token token = m_scanner->currentToken(); - if (_allowModifiers && token == Token::Identifier) + if (_allowFuncDef && token == Token::Identifier) { // If the name is empty (and this is not a constructor), // then this can either be a modifier (fallback function declaration) @@ -493,6 +524,13 @@ Parser::FunctionHeaderParserResult Parser::parseFunctionHeader(bool _forceEmptyN else result.stateMutability = parseStateMutability(); } + else if (_allowFuncDef && token == Token::Override) + { + if (result.overrides) + parserError("Override already specified."); + + result.overrides = parseOverrideSpecifier(); + } else break; } @@ -521,6 +559,7 @@ ASTPointer Parser::parseFunctionDefinitionOrFunctionTypeStateVariable() header.isConstructor || !header.modifiers.empty() || !header.name->empty() || + header.overrides || m_scanner->currentToken() == Token::Semicolon || m_scanner->currentToken() == Token::LBrace ) @@ -540,6 +579,7 @@ ASTPointer Parser::parseFunctionDefinitionOrFunctionTypeStateVariable() header.visibility, header.stateMutability, header.isConstructor, + header.overrides, docstring, header.parameters, header.modifiers, @@ -637,6 +677,7 @@ ASTPointer Parser::parseVariableDeclaration( } bool isIndexed = false; bool isDeclaredConst = false; + ASTPointer overrides = nullptr; Declaration::Visibility visibility(Declaration::Visibility::Default); VariableDeclaration::Location location = VariableDeclaration::Location::Unspecified; ASTPointer identifier; @@ -659,6 +700,13 @@ ASTPointer Parser::parseVariableDeclaration( else visibility = parseVisibilitySpecifier(); } + else if (_options.isStateVariable && token == Token::Override) + { + if (overrides) + parserError("Override already specified."); + + overrides = parseOverrideSpecifier(); + } else { if (_options.allowIndexed && token == Token::Indexed) @@ -724,6 +772,7 @@ ASTPointer Parser::parseVariableDeclaration( _options.isStateVariable, isIndexed, isDeclaredConst, + overrides, location ); } diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index cb3d75f51..b0e1c6716 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -71,6 +71,7 @@ private: struct FunctionHeaderParserResult { bool isConstructor; + ASTPointer overrides; ASTPointer name; ASTPointer parameters; ASTPointer returnParameters; @@ -88,8 +89,9 @@ private: ASTPointer parseContractDefinition(); ASTPointer parseInheritanceSpecifier(); Declaration::Visibility parseVisibilitySpecifier(); + ASTPointer parseOverrideSpecifier(); StateMutability parseStateMutability(); - FunctionHeaderParserResult parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers); + FunctionHeaderParserResult parseFunctionHeader(bool _onlyFuncType, bool _allowFuncDef); ASTPointer parseFunctionDefinitionOrFunctionTypeStateVariable(); ASTPointer parseFunctionDefinition(ASTString const* _contractName); ASTPointer parseStructDefinition(); diff --git a/test/cmdlineTests/standard_only_ast_requested/output.json b/test/cmdlineTests/standard_only_ast_requested/output.json index b884ab7df..212429661 100644 --- a/test/cmdlineTests/standard_only_ast_requested/output.json +++ b/test/cmdlineTests/standard_only_ast_requested/output.json @@ -1 +1 @@ -{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"0:22:0"},{"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"61:2:0","statements":[]},"documentation":null,"id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"46:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"61:0:0"},"scope":6,"src":"36:27:0","stateMutability":"pure","superFunction":null,"visibility":"public"}],"scope":7,"src":"23:42:0"}],"src":"0:65:0"},"id":0}}} +{"sources":{"A":{"ast":{"absolutePath":"A","exportedSymbols":{"C":[6]},"id":7,"nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"0:22:0"},{"baseContracts":[],"contractDependencies":[],"contractKind":"contract","documentation":null,"fullyImplemented":true,"id":6,"linearizedBaseContracts":[6],"name":"C","nodeType":"ContractDefinition","nodes":[{"body":{"id":4,"nodeType":"Block","src":"61:2:0","statements":[]},"documentation":null,"id":5,"implemented":true,"kind":"function","modifiers":[],"name":"f","nodeType":"FunctionDefinition","overrides":null,"parameters":{"id":2,"nodeType":"ParameterList","parameters":[],"src":"46:2:0"},"returnParameters":{"id":3,"nodeType":"ParameterList","parameters":[],"src":"61:0:0"},"scope":6,"src":"36:27:0","stateMutability":"pure","superFunction":null,"visibility":"public"}],"scope":7,"src":"23:42:0"}],"src":"0:65:0"},"id":0}}} diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index c8b71628c..88ce272dc 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -31,6 +31,7 @@ "id" : 4, "name" : "m", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 37, "src" : "17:44:1", "stateVariable" : true, @@ -99,6 +100,7 @@ "id" : 12, "name" : "a", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 35, "src" : "144:17:1", "stateVariable" : false, @@ -239,6 +241,7 @@ "id" : 22, "name" : "c", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 35, "src" : "197:9:1", "stateVariable" : false, @@ -467,6 +470,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 7, @@ -478,6 +482,7 @@ "id" : 6, "name" : "arg", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 36, "src" : "78:19:1", "stateVariable" : false, @@ -517,6 +522,7 @@ "id" : 9, "name" : "r", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 36, "src" : "115:17:1", "stateVariable" : false, diff --git a/test/libsolidity/ASTJSON/address_payable_legacy.json b/test/libsolidity/ASTJSON/address_payable_legacy.json index 8abebce08..a2758b16b 100644 --- a/test/libsolidity/ASTJSON/address_payable_legacy.json +++ b/test/libsolidity/ASTJSON/address_payable_legacy.json @@ -40,6 +40,7 @@ { "constant" : false, "name" : "m", + "overrides" : null, "scope" : 37, "stateVariable" : true, "storageLocation" : "default", @@ -99,6 +100,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 37, "stateMutability" : "nonpayable", "superFunction" : null, @@ -114,6 +116,7 @@ { "constant" : false, "name" : "arg", + "overrides" : null, "scope" : 36, "stateVariable" : false, "storageLocation" : "default", @@ -152,6 +155,7 @@ { "constant" : false, "name" : "r", + "overrides" : null, "scope" : 36, "stateVariable" : false, "storageLocation" : "default", @@ -200,6 +204,7 @@ { "constant" : false, "name" : "a", + "overrides" : null, "scope" : 35, "stateVariable" : false, "storageLocation" : "default", @@ -352,6 +357,7 @@ { "constant" : false, "name" : "c", + "overrides" : null, "scope" : 35, "stateVariable" : false, "storageLocation" : "default", diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json index e3a3bea94..bc783ef88 100644 --- a/test/libsolidity/ASTJSON/array_type_name.json +++ b/test/libsolidity/ASTJSON/array_type_name.json @@ -31,6 +31,7 @@ "id" : 3, "name" : "i", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 4, "src" : "13:8:1", "stateVariable" : true, diff --git a/test/libsolidity/ASTJSON/array_type_name.sol b/test/libsolidity/ASTJSON/array_type_name.sol index 202ecf02b..97ed03510 100644 --- a/test/libsolidity/ASTJSON/array_type_name.sol +++ b/test/libsolidity/ASTJSON/array_type_name.sol @@ -1 +1,3 @@ contract C { uint[] i; } + +// ---- diff --git a/test/libsolidity/ASTJSON/array_type_name_legacy.json b/test/libsolidity/ASTJSON/array_type_name_legacy.json index 80feb344b..749a49a69 100644 --- a/test/libsolidity/ASTJSON/array_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/array_type_name_legacy.json @@ -40,6 +40,7 @@ { "constant" : false, "name" : "i", + "overrides" : null, "scope" : 4, "stateVariable" : true, "storageLocation" : "default", diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index b0bc42019..d6a0d47ba 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -41,6 +41,7 @@ "modifiers" : [], "name" : "", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/constructor.sol b/test/libsolidity/ASTJSON/constructor.sol index 79d04eb5a..f89ac45b4 100644 --- a/test/libsolidity/ASTJSON/constructor.sol +++ b/test/libsolidity/ASTJSON/constructor.sol @@ -2,3 +2,5 @@ contract C { constructor() public { } } + +// ---- diff --git a/test/libsolidity/ASTJSON/constructor_legacy.json b/test/libsolidity/ASTJSON/constructor_legacy.json index 0617073e3..c5e1d3a14 100644 --- a/test/libsolidity/ASTJSON/constructor_legacy.json +++ b/test/libsolidity/ASTJSON/constructor_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "", + "overrides" : null, "scope" : 5, "stateMutability" : "nonpayable", "superFunction" : null, diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index ce1e0b57a..a761c836c 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -151,6 +151,7 @@ "modifiers" : [], "name" : "fn", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 11, diff --git a/test/libsolidity/ASTJSON/documentation.sol b/test/libsolidity/ASTJSON/documentation.sol index e65af9b44..5c5fe7d2b 100644 --- a/test/libsolidity/ASTJSON/documentation.sol +++ b/test/libsolidity/ASTJSON/documentation.sol @@ -15,3 +15,5 @@ contract C { /** Some comment on mod.*/ modifier mod() { _; } /** Some comment on fn.*/ function fn() public {} } + +// ---- diff --git a/test/libsolidity/ASTJSON/documentation_legacy.json b/test/libsolidity/ASTJSON/documentation_legacy.json index 0277902f8..1dc3d9a4a 100644 --- a/test/libsolidity/ASTJSON/documentation_legacy.json +++ b/test/libsolidity/ASTJSON/documentation_legacy.json @@ -114,6 +114,7 @@ null ], "name" : "fn", + "overrides" : null, "scope" : 15, "stateMutability" : "nonpayable", "superFunction" : null, diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index a9c85b2fb..6374051d4 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -41,6 +41,7 @@ "modifiers" : [], "name" : "", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/fallback.sol b/test/libsolidity/ASTJSON/fallback.sol index 4e318892e..7d346042d 100644 --- a/test/libsolidity/ASTJSON/fallback.sol +++ b/test/libsolidity/ASTJSON/fallback.sol @@ -2,3 +2,5 @@ contract C { function() external payable { } } + +// ---- diff --git a/test/libsolidity/ASTJSON/fallback_legacy.json b/test/libsolidity/ASTJSON/fallback_legacy.json index 0aca3128e..4e31a33ea 100644 --- a/test/libsolidity/ASTJSON/fallback_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "", + "overrides" : null, "scope" : 5, "stateMutability" : "payable", "superFunction" : null, diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index 9d56f74bd..49a7a33a9 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -41,6 +41,7 @@ "modifiers" : [], "name" : "", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/fallback_payable.sol b/test/libsolidity/ASTJSON/fallback_payable.sol index 21db99ecd..4a3cee6b5 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.sol +++ b/test/libsolidity/ASTJSON/fallback_payable.sol @@ -1,3 +1,5 @@ contract C { function() external {} } + +// ---- diff --git a/test/libsolidity/ASTJSON/fallback_payable_legacy.json b/test/libsolidity/ASTJSON/fallback_payable_legacy.json index 7320f574a..af148555b 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_legacy.json +++ b/test/libsolidity/ASTJSON/fallback_payable_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "", + "overrides" : null, "scope" : 5, "stateMutability" : "nonpayable", "superFunction" : null, diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index b78d84463..8e60d2ef1 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -41,6 +41,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 7, @@ -52,6 +53,7 @@ "id" : 6, "name" : "x", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 16, "src" : "24:44:1", "stateVariable" : false, @@ -83,6 +85,7 @@ "id" : 3, "name" : "", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 5, "src" : "61:4:1", "stateVariable" : false, @@ -136,6 +139,7 @@ "id" : 13, "name" : "", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 16, "src" : "79:40:1", "stateVariable" : false, @@ -167,6 +171,7 @@ "id" : 10, "name" : "", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 12, "src" : "113:4:1", "stateVariable" : false, diff --git a/test/libsolidity/ASTJSON/function_type_legacy.json b/test/libsolidity/ASTJSON/function_type_legacy.json index 72ceec81e..90b5a8e4d 100644 --- a/test/libsolidity/ASTJSON/function_type_legacy.json +++ b/test/libsolidity/ASTJSON/function_type_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 17, "stateMutability" : "nonpayable", "superFunction" : null, @@ -62,6 +63,7 @@ { "constant" : false, "name" : "x", + "overrides" : null, "scope" : 16, "stateVariable" : false, "storageLocation" : "default", @@ -101,6 +103,7 @@ { "constant" : false, "name" : "", + "overrides" : null, "scope" : 5, "stateVariable" : false, "storageLocation" : "default", @@ -153,6 +156,7 @@ { "constant" : false, "name" : "", + "overrides" : null, "scope" : 16, "stateVariable" : false, "storageLocation" : "default", @@ -192,6 +196,7 @@ { "constant" : false, "name" : "", + "overrides" : null, "scope" : 12, "stateVariable" : false, "storageLocation" : "default", diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index c6d40af24..acc60daf0 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -46,6 +46,7 @@ "id" : 4, "name" : "a", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 9, "src" : "35:6:1", "stateVariable" : false, @@ -146,6 +147,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol index f07029d7a..745b14ae8 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.sol @@ -1 +1,3 @@ contract c { function f() public { uint a = 2 + 3; } } + +// ---- diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json index b53332860..cccf82f6d 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 11, "stateMutability" : "nonpayable", "superFunction" : null, @@ -98,6 +99,7 @@ { "constant" : false, "name" : "a", + "overrides" : null, "scope" : 9, "stateVariable" : false, "storageLocation" : "default", diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index 505d260c4..dc0c6447f 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -31,6 +31,7 @@ "id" : 3, "name" : "a", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 14, "src" : "13:8:1", "stateVariable" : true, @@ -87,6 +88,7 @@ "id" : 9, "name" : "b", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 12, "src" : "45:16:1", "stateVariable" : false, @@ -152,6 +154,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 4, diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.sol b/test/libsolidity/ASTJSON/long_type_name_identifier.sol index f03f7a84d..60193cebb 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.sol +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.sol @@ -1 +1,3 @@ contract c { uint[] a; function f() public { uint[] storage b = a; } } + +// ---- diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json index d3bcda561..457677089 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_legacy.json @@ -40,6 +40,7 @@ { "constant" : false, "name" : "a", + "overrides" : null, "scope" : 14, "stateVariable" : true, "storageLocation" : "default", @@ -89,6 +90,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 14, "stateMutability" : "nonpayable", "superFunction" : null, @@ -140,6 +142,7 @@ { "constant" : false, "name" : "b", + "overrides" : null, "scope" : 12, "stateVariable" : false, "storageLocation" : "storage", diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index 66359453c..0e512e804 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -56,6 +56,7 @@ "id" : 2, "name" : "i", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 6, "src" : "24:6:1", "stateVariable" : false, @@ -145,6 +146,7 @@ ], "name" : "F", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 7, diff --git a/test/libsolidity/ASTJSON/modifier_definition.sol b/test/libsolidity/ASTJSON/modifier_definition.sol index 96474e0f3..1dcdb5946 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.sol +++ b/test/libsolidity/ASTJSON/modifier_definition.sol @@ -1 +1,3 @@ contract C { modifier M(uint i) { _; } function F() M(1) public {} } + +// ---- diff --git a/test/libsolidity/ASTJSON/modifier_definition_legacy.json b/test/libsolidity/ASTJSON/modifier_definition_legacy.json index 5186912c8..5bb91624e 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_definition_legacy.json @@ -52,6 +52,7 @@ { "constant" : false, "name" : "i", + "overrides" : null, "scope" : 6, "stateVariable" : false, "storageLocation" : "default", @@ -107,6 +108,7 @@ "isConstructor" : false, "kind" : "function", "name" : "F", + "overrides" : null, "scope" : 14, "stateMutability" : "nonpayable", "superFunction" : null, diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index 66359453c..0e512e804 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -56,6 +56,7 @@ "id" : 2, "name" : "i", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 6, "src" : "24:6:1", "stateVariable" : false, @@ -145,6 +146,7 @@ ], "name" : "F", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 7, diff --git a/test/libsolidity/ASTJSON/modifier_invocation.sol b/test/libsolidity/ASTJSON/modifier_invocation.sol index 96474e0f3..1dcdb5946 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.sol +++ b/test/libsolidity/ASTJSON/modifier_invocation.sol @@ -1 +1,3 @@ contract C { modifier M(uint i) { _; } function F() M(1) public {} } + +// ---- diff --git a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json index 5186912c8..5bb91624e 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_legacy.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_legacy.json @@ -52,6 +52,7 @@ { "constant" : false, "name" : "i", + "overrides" : null, "scope" : 6, "stateVariable" : false, "storageLocation" : "default", @@ -107,6 +108,7 @@ "isConstructor" : false, "kind" : "function", "name" : "F", + "overrides" : null, "scope" : 14, "stateMutability" : "nonpayable", "superFunction" : null, diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 1852bd38f..99312bd46 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -46,6 +46,7 @@ "id" : 3, "name" : "x", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 6, "src" : "35:5:1", "stateVariable" : false, @@ -93,6 +94,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/non_utf8.sol b/test/libsolidity/ASTJSON/non_utf8.sol index b83f3d706..f9a79d2fa 100644 --- a/test/libsolidity/ASTJSON/non_utf8.sol +++ b/test/libsolidity/ASTJSON/non_utf8.sol @@ -1 +1,3 @@ contract C { function f() public { var x = hex"ff"; } } + +// ---- diff --git a/test/libsolidity/ASTJSON/non_utf8_legacy.json b/test/libsolidity/ASTJSON/non_utf8_legacy.json index df1050966..5abbce974 100644 --- a/test/libsolidity/ASTJSON/non_utf8_legacy.json +++ b/test/libsolidity/ASTJSON/non_utf8_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 8, "stateMutability" : "nonpayable", "superFunction" : null, @@ -98,6 +99,7 @@ { "constant" : false, "name" : "x", + "overrides" : null, "scope" : 6, "stateVariable" : false, "storageLocation" : "default", diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json new file mode 100644 index 000000000..976ae7c1d --- /dev/null +++ b/test/libsolidity/ASTJSON/override.json @@ -0,0 +1,337 @@ +{ + "absolutePath" : "a", + "exportedSymbols" : + { + "A" : + [ + 5 + ], + "B" : + [ + 16 + ], + "C" : + [ + 31 + ] + }, + "id" : 32, + "nodeType" : "SourceUnit", + "nodes" : + [ + { + "baseContracts" : [], + "contractDependencies" : [], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : true, + "id" : 5, + "linearizedBaseContracts" : + [ + 5 + ], + "name" : "A", + "nodeType" : "ContractDefinition", + "nodes" : + [ + { + "body" : + { + "id" : 3, + "nodeType" : "Block", + "src" : "36:2:1", + "statements" : [] + }, + "documentation" : null, + "id" : 4, + "implemented" : true, + "kind" : "function", + "modifiers" : [], + "name" : "faa", + "nodeType" : "FunctionDefinition", + "overrides" : null, + "parameters" : + { + "id" : 1, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "26:2:1" + }, + "returnParameters" : + { + "id" : 2, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "36:0:1" + }, + "scope" : 5, + "src" : "14:24:1", + "stateMutability" : "nonpayable", + "superFunction" : null, + "visibility" : "public" + } + ], + "scope" : 32, + "src" : "0:40:1" + }, + { + "baseContracts" : + [ + { + "arguments" : null, + "baseName" : + { + "contractScope" : null, + "id" : 6, + "name" : "A", + "nodeType" : "UserDefinedTypeName", + "referencedDeclaration" : 5, + "src" : "55:1:1", + "typeDescriptions" : + { + "typeIdentifier" : "t_contract$_A_$5", + "typeString" : "contract A" + } + }, + "id" : 7, + "nodeType" : "InheritanceSpecifier", + "src" : "55:1:1" + } + ], + "contractDependencies" : + [ + 5 + ], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : false, + "id" : 16, + "linearizedBaseContracts" : + [ + 16, + 5 + ], + "name" : "B", + "nodeType" : "ContractDefinition", + "nodes" : + [ + { + "body" : null, + "documentation" : null, + "id" : 10, + "implemented" : false, + "kind" : "function", + "modifiers" : [], + "name" : "foo", + "nodeType" : "FunctionDefinition", + "overrides" : null, + "parameters" : + { + "id" : 8, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "72:2:1" + }, + "returnParameters" : + { + "id" : 9, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "81:0:1" + }, + "scope" : 16, + "src" : "60:22:1", + "stateMutability" : "nonpayable", + "superFunction" : null, + "visibility" : "public" + }, + { + "body" : + { + "id" : 14, + "nodeType" : "Block", + "src" : "115:2:1", + "statements" : [] + }, + "documentation" : null, + "id" : 15, + "implemented" : true, + "kind" : "function", + "modifiers" : [], + "name" : "faa", + "nodeType" : "FunctionDefinition", + "overrides" : [], + "parameters" : + { + "id" : 11, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "96:2:1" + }, + "returnParameters" : + { + "id" : 13, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "115:0:1" + }, + "scope" : 16, + "src" : "84:33:1", + "stateMutability" : "nonpayable", + "superFunction" : 4, + "visibility" : "public" + } + ], + "scope" : 32, + "src" : "41:78:1" + }, + { + "baseContracts" : + [ + { + "arguments" : null, + "baseName" : + { + "contractScope" : null, + "id" : 17, + "name" : "B", + "nodeType" : "UserDefinedTypeName", + "referencedDeclaration" : 16, + "src" : "134:1:1", + "typeDescriptions" : + { + "typeIdentifier" : "t_contract$_B_$16", + "typeString" : "contract B" + } + }, + "id" : 18, + "nodeType" : "InheritanceSpecifier", + "src" : "134:1:1" + } + ], + "contractDependencies" : + [ + 5, + 16 + ], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : true, + "id" : 31, + "linearizedBaseContracts" : + [ + 31, + 16, + 5 + ], + "name" : "C", + "nodeType" : "ContractDefinition", + "nodes" : + [ + { + "body" : + { + "id" : 22, + "nodeType" : "Block", + "src" : "170:3:1", + "statements" : [] + }, + "documentation" : null, + "id" : 23, + "implemented" : true, + "kind" : "function", + "modifiers" : [], + "name" : "foo", + "nodeType" : "FunctionDefinition", + "overrides" : [], + "parameters" : + { + "id" : 19, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "151:2:1" + }, + "returnParameters" : + { + "id" : 21, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "170:0:1" + }, + "scope" : 31, + "src" : "139:34:1", + "stateMutability" : "nonpayable", + "superFunction" : 10, + "visibility" : "public" + }, + { + "body" : + { + "id" : 29, + "nodeType" : "Block", + "src" : "212:2:1", + "statements" : [] + }, + "documentation" : null, + "id" : 30, + "implemented" : true, + "kind" : "function", + "modifiers" : [], + "name" : "faa", + "nodeType" : "FunctionDefinition", + "overrides" : + [ + { + "contractScope" : null, + "id" : 25, + "name" : "A", + "nodeType" : "UserDefinedTypeName", + "referencedDeclaration" : 5, + "src" : "206:1:1", + "typeDescriptions" : + { + "typeIdentifier" : "t_contract$_A_$5", + "typeString" : "contract A" + } + }, + { + "contractScope" : null, + "id" : 26, + "name" : "B", + "nodeType" : "UserDefinedTypeName", + "referencedDeclaration" : 16, + "src" : "209:1:1", + "typeDescriptions" : + { + "typeIdentifier" : "t_contract$_B_$16", + "typeString" : "contract B" + } + } + ], + "parameters" : + { + "id" : 24, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "187:2:1" + }, + "returnParameters" : + { + "id" : 28, + "nodeType" : "ParameterList", + "parameters" : [], + "src" : "212:0:1" + }, + "scope" : 31, + "src" : "175:39:1", + "stateMutability" : "nonpayable", + "superFunction" : 15, + "visibility" : "public" + } + ], + "scope" : 32, + "src" : "120:96:1" + } + ], + "src" : "0:217:1" +} diff --git a/test/libsolidity/ASTJSON/override.sol b/test/libsolidity/ASTJSON/override.sol new file mode 100644 index 000000000..3edb20df0 --- /dev/null +++ b/test/libsolidity/ASTJSON/override.sol @@ -0,0 +1,13 @@ +contract A { + function faa() public {} +} +contract B is A { + function foo() public; + function faa() public override {} +} +contract C is B { + function foo() public override { } + function faa() public override(A, B) {} +} + +// ---- diff --git a/test/libsolidity/ASTJSON/override_legacy.json b/test/libsolidity/ASTJSON/override_legacy.json new file mode 100644 index 000000000..d7ef04356 --- /dev/null +++ b/test/libsolidity/ASTJSON/override_legacy.json @@ -0,0 +1,492 @@ +{ + "attributes" : + { + "absolutePath" : "a", + "exportedSymbols" : + { + "A" : + [ + 5 + ], + "B" : + [ + 16 + ], + "C" : + [ + 31 + ] + } + }, + "children" : + [ + { + "attributes" : + { + "baseContracts" : + [ + null + ], + "contractDependencies" : + [ + null + ], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : true, + "linearizedBaseContracts" : + [ + 5 + ], + "name" : "A", + "scope" : 32 + }, + "children" : + [ + { + "attributes" : + { + "documentation" : null, + "implemented" : true, + "isConstructor" : false, + "kind" : "function", + "modifiers" : + [ + null + ], + "name" : "faa", + "overrides" : null, + "scope" : 5, + "stateMutability" : "nonpayable", + "superFunction" : null, + "visibility" : "public" + }, + "children" : + [ + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 1, + "name" : "ParameterList", + "src" : "26:2:1" + }, + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 2, + "name" : "ParameterList", + "src" : "36:0:1" + }, + { + "attributes" : + { + "statements" : + [ + null + ] + }, + "children" : [], + "id" : 3, + "name" : "Block", + "src" : "36:2:1" + } + ], + "id" : 4, + "name" : "FunctionDefinition", + "src" : "14:24:1" + } + ], + "id" : 5, + "name" : "ContractDefinition", + "src" : "0:40:1" + }, + { + "attributes" : + { + "contractDependencies" : + [ + 5 + ], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : false, + "linearizedBaseContracts" : + [ + 16, + 5 + ], + "name" : "B", + "scope" : 32 + }, + "children" : + [ + { + "attributes" : + { + "arguments" : null + }, + "children" : + [ + { + "attributes" : + { + "contractScope" : null, + "name" : "A", + "referencedDeclaration" : 5, + "type" : "contract A" + }, + "id" : 6, + "name" : "UserDefinedTypeName", + "src" : "55:1:1" + } + ], + "id" : 7, + "name" : "InheritanceSpecifier", + "src" : "55:1:1" + }, + { + "attributes" : + { + "body" : null, + "documentation" : null, + "implemented" : false, + "isConstructor" : false, + "kind" : "function", + "modifiers" : + [ + null + ], + "name" : "foo", + "overrides" : null, + "scope" : 16, + "stateMutability" : "nonpayable", + "superFunction" : null, + "visibility" : "public" + }, + "children" : + [ + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 8, + "name" : "ParameterList", + "src" : "72:2:1" + }, + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 9, + "name" : "ParameterList", + "src" : "81:0:1" + } + ], + "id" : 10, + "name" : "FunctionDefinition", + "src" : "60:22:1" + }, + { + "attributes" : + { + "documentation" : null, + "implemented" : true, + "isConstructor" : false, + "kind" : "function", + "modifiers" : + [ + null + ], + "name" : "faa", + "overrides" : + [ + null + ], + "scope" : 16, + "stateMutability" : "nonpayable", + "superFunction" : 4, + "visibility" : "public" + }, + "children" : + [ + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 11, + "name" : "ParameterList", + "src" : "96:2:1" + }, + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 13, + "name" : "ParameterList", + "src" : "115:0:1" + }, + { + "attributes" : + { + "statements" : + [ + null + ] + }, + "children" : [], + "id" : 14, + "name" : "Block", + "src" : "115:2:1" + } + ], + "id" : 15, + "name" : "FunctionDefinition", + "src" : "84:33:1" + } + ], + "id" : 16, + "name" : "ContractDefinition", + "src" : "41:78:1" + }, + { + "attributes" : + { + "contractDependencies" : + [ + 5, + 16 + ], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : true, + "linearizedBaseContracts" : + [ + 31, + 16, + 5 + ], + "name" : "C", + "scope" : 32 + }, + "children" : + [ + { + "attributes" : + { + "arguments" : null + }, + "children" : + [ + { + "attributes" : + { + "contractScope" : null, + "name" : "B", + "referencedDeclaration" : 16, + "type" : "contract B" + }, + "id" : 17, + "name" : "UserDefinedTypeName", + "src" : "134:1:1" + } + ], + "id" : 18, + "name" : "InheritanceSpecifier", + "src" : "134:1:1" + }, + { + "attributes" : + { + "documentation" : null, + "implemented" : true, + "isConstructor" : false, + "kind" : "function", + "modifiers" : + [ + null + ], + "name" : "foo", + "overrides" : + [ + null + ], + "scope" : 31, + "stateMutability" : "nonpayable", + "superFunction" : 10, + "visibility" : "public" + }, + "children" : + [ + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 19, + "name" : "ParameterList", + "src" : "151:2:1" + }, + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 21, + "name" : "ParameterList", + "src" : "170:0:1" + }, + { + "attributes" : + { + "statements" : + [ + null + ] + }, + "children" : [], + "id" : 22, + "name" : "Block", + "src" : "170:3:1" + } + ], + "id" : 23, + "name" : "FunctionDefinition", + "src" : "139:34:1" + }, + { + "attributes" : + { + "documentation" : null, + "implemented" : true, + "isConstructor" : false, + "kind" : "function", + "modifiers" : + [ + null + ], + "name" : "faa", + "scope" : 31, + "stateMutability" : "nonpayable", + "superFunction" : 15, + "visibility" : "public" + }, + "children" : + [ + { + "attributes" : + { + "contractScope" : null, + "name" : "A", + "referencedDeclaration" : 5, + "type" : "contract A" + }, + "id" : 25, + "name" : "UserDefinedTypeName", + "src" : "206:1:1" + }, + { + "attributes" : + { + "contractScope" : null, + "name" : "B", + "referencedDeclaration" : 16, + "type" : "contract B" + }, + "id" : 26, + "name" : "UserDefinedTypeName", + "src" : "209:1:1" + }, + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 24, + "name" : "ParameterList", + "src" : "187:2:1" + }, + { + "attributes" : + { + "parameters" : + [ + null + ] + }, + "children" : [], + "id" : 28, + "name" : "ParameterList", + "src" : "212:0:1" + }, + { + "attributes" : + { + "statements" : + [ + null + ] + }, + "children" : [], + "id" : 29, + "name" : "Block", + "src" : "212:2:1" + } + ], + "id" : 30, + "name" : "FunctionDefinition", + "src" : "175:39:1" + } + ], + "id" : 31, + "name" : "ContractDefinition", + "src" : "120:96:1" + } + ], + "id" : 32, + "name" : "SourceUnit", + "src" : "0:217:1" +} diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index acb461571..823d04d3d 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -46,6 +46,7 @@ "id" : 6, "name" : "x", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 8, "src" : "35:15:1", "stateVariable" : false, @@ -97,6 +98,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/short_type_name.sol b/test/libsolidity/ASTJSON/short_type_name.sol index 533874ae4..077e715b9 100644 --- a/test/libsolidity/ASTJSON/short_type_name.sol +++ b/test/libsolidity/ASTJSON/short_type_name.sol @@ -1 +1,3 @@ contract c { function f() public { uint[] memory x; } } + +// ---- diff --git a/test/libsolidity/ASTJSON/short_type_name_legacy.json b/test/libsolidity/ASTJSON/short_type_name_legacy.json index 1f9b19687..ee4d1fce3 100644 --- a/test/libsolidity/ASTJSON/short_type_name_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 10, "stateMutability" : "nonpayable", "superFunction" : null, @@ -99,6 +100,7 @@ { "constant" : false, "name" : "x", + "overrides" : null, "scope" : 8, "stateVariable" : false, "storageLocation" : "memory", diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index b6b7bca5d..5224f26f2 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -46,6 +46,7 @@ "id" : 7, "name" : "rows", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 9, "src" : "35:20:1", "stateVariable" : false, @@ -109,6 +110,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.sol b/test/libsolidity/ASTJSON/short_type_name_ref.sol index a808b982b..9128d69d6 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.sol +++ b/test/libsolidity/ASTJSON/short_type_name_ref.sol @@ -1 +1,3 @@ contract c { function f() public { uint[][] memory rows; } } + +// ---- diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json index 420b0f609..0fbecedf8 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 11, "stateMutability" : "nonpayable", "superFunction" : null, @@ -99,6 +100,7 @@ { "constant" : false, "name" : "rows", + "overrides" : null, "scope" : 9, "stateVariable" : false, "storageLocation" : "memory", diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index f0ed216db..0a3c9ccd6 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -46,6 +46,7 @@ "id" : 3, "name" : "x", "nodeType" : "VariableDeclaration", + "overrides" : null, "scope" : 9, "src" : "28:5:1", "stateVariable" : false, @@ -131,6 +132,7 @@ "modifiers" : [], "name" : "f", "nodeType" : "FunctionDefinition", + "overrides" : null, "parameters" : { "id" : 1, diff --git a/test/libsolidity/ASTJSON/source_location.sol b/test/libsolidity/ASTJSON/source_location.sol index 1fcec2e66..1b763646d 100644 --- a/test/libsolidity/ASTJSON/source_location.sol +++ b/test/libsolidity/ASTJSON/source_location.sol @@ -1 +1,3 @@ contract C { function f() { var x = 2; x++; } } + +// ---- diff --git a/test/libsolidity/ASTJSON/source_location_legacy.json b/test/libsolidity/ASTJSON/source_location_legacy.json index a65979d66..3c56e55f4 100644 --- a/test/libsolidity/ASTJSON/source_location_legacy.json +++ b/test/libsolidity/ASTJSON/source_location_legacy.json @@ -47,6 +47,7 @@ null ], "name" : "f", + "overrides" : null, "scope" : 11, "stateMutability" : "nonpayable", "superFunction" : null, @@ -98,6 +99,7 @@ { "constant" : false, "name" : "x", + "overrides" : null, "scope" : 9, "stateVariable" : false, "storageLocation" : "default", diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 48ac00613..0979ce6b9 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -545,7 +545,6 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved) "mutable", "null", "of", - "override", "partial", "promise", "reference", diff --git a/test/libsolidity/syntaxTests/inheritance/override/detect_double_override.sol b/test/libsolidity/syntaxTests/inheritance/override/detect_double_override.sol new file mode 100644 index 000000000..60138f48d --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/detect_double_override.sol @@ -0,0 +1,7 @@ +contract X { + int public override override testvar; + function test() internal override override returns (uint256); +} +// ---- +// ParserError: (34-42): Override already specified. +// ParserError: (87-95): Override already specified. diff --git a/test/libsolidity/syntaxTests/inheritance/override/override.sol b/test/libsolidity/syntaxTests/inheritance/override/override.sol new file mode 100644 index 000000000..bb7aa7347 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override.sol @@ -0,0 +1,5 @@ +contract X { + int public override testvar; + function test() internal override returns (uint256); +} +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_empty_list.sol b/test/libsolidity/syntaxTests/inheritance/override/override_empty_list.sol new file mode 100644 index 000000000..2db86a1af --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_empty_list.sol @@ -0,0 +1,10 @@ +contract A { + int public testvar; + function test() internal returns (uint256); +} +contract X is A { + int public override testvar; + function test() internal override() returns (uint256); +} +// ---- +// ParserError: (164-165): Expected identifier but got ')' diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_multiple.sol b/test/libsolidity/syntaxTests/inheritance/override/override_multiple.sol new file mode 100644 index 000000000..0b16056a6 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_multiple.sol @@ -0,0 +1,9 @@ +contract A { + function foo() internal returns (uint256); +} +contract X { + int public override testvar; + function test() internal override returns (uint256); + function foo() internal override(X, A) returns (uint256); +} +// ---- diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail1.sol b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail1.sol new file mode 100644 index 000000000..ebbf83e16 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail1.sol @@ -0,0 +1,8 @@ +contract A { + function foo() internal returns (uint256); +} +contract X { + int public override(A,) testvar; +} +// ---- +// ParserError: (95-96): Expected identifier but got ')' diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail2.sol b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail2.sol new file mode 100644 index 000000000..2c3319ac2 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail2.sol @@ -0,0 +1,8 @@ +contract A { + function foo() internal returns (uint256); +} +contract X { + function test() internal override(,) returns (uint256); +} +// ---- +// ParserError: (107-108): Expected identifier but got ',' diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail3.sol b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail3.sol new file mode 100644 index 000000000..79ab20d8b --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail3.sol @@ -0,0 +1,8 @@ +contract A { + function foo() internal returns (uint256); +} +contract X { + function foo() internal override(X, address) returns (uint256); +} +// ---- +// ParserError: (109-116): Expected identifier but got 'address' diff --git a/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail4.sol b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail4.sol new file mode 100644 index 000000000..d97fb27d6 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/override_multiple_fail4.sol @@ -0,0 +1,8 @@ +contract A { + function foo() internal returns (uint256); +} +contract X { + int public override() testvar; +} +// ---- +// ParserError: (93-94): Expected identifier but got ')'