Merge pull request #7233 from ethereum/override-5424

Implement parsing of override keyword
This commit is contained in:
Mathias L. Baumann 2019-08-26 18:12:28 +02:00 committed by GitHub
commit 25a3a83b34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 1127 additions and 7 deletions

View File

@ -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) \

View File

@ -604,6 +604,32 @@ protected:
ASTPointer<ParameterList> 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<ASTPointer<UserDefinedTypeName>> 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<ASTPointer<UserDefinedTypeName>> const& overrides() const { return m_overrides; }
protected:
std::vector<ASTPointer<UserDefinedTypeName>> m_overrides;
};
class FunctionDefinition: public CallableDeclaration, public Documented, public ImplementationOptional
{
public:
@ -613,6 +639,7 @@ public:
Declaration::Visibility _visibility,
StateMutability _stateMutability,
bool _isConstructor,
ASTPointer<OverrideSpecifier> const& _overrides,
ASTPointer<ASTString> const& _documentation,
ASTPointer<ParameterList> const& _parameters,
std::vector<ASTPointer<ModifierInvocation>> 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<OverrideSpecifier> const& overrides() const { return m_overrides; }
bool isFallback() const { return !m_isConstructor && name().empty(); }
bool isPayable() const { return m_stateMutability == StateMutability::Payable; }
std::vector<ASTPointer<ModifierInvocation>> const& modifiers() const { return m_functionModifiers; }
@ -661,6 +690,7 @@ public:
private:
StateMutability m_stateMutability;
bool m_isConstructor;
ASTPointer<OverrideSpecifier> m_overrides;
std::vector<ASTPointer<ModifierInvocation>> m_functionModifiers;
ASTPointer<Block> m_body;
};
@ -683,6 +713,7 @@ public:
bool _isStateVar = false,
bool _isIndexed = false,
bool _isConstant = false,
ASTPointer<OverrideSpecifier> 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<OverrideSpecifier> const& overrides() const { return m_overrides; }
Location referenceLocation() const { return m_location; }
/// @returns a set of allowed storage locations for the variable.
std::set<Location> 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<OverrideSpecifier> m_overrides; ///< Contains the override specifier node
Location m_location; ///< Location of the variable if it is of reference type.
};

View File

@ -39,6 +39,7 @@ class PragmaDirective;
class ImportDirective;
class Declaration;
class CallableDeclaration;
class OverrideSpecifier;
class ContractDefinition;
class InheritanceSpecifier;
class UsingForDirective;

View File

@ -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())),

View File

@ -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--;

View File

@ -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;

View File

@ -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); }

View File

@ -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);

View File

@ -382,6 +382,36 @@ Declaration::Visibility Parser::parseVisibilitySpecifier()
return visibility;
}
ASTPointer<OverrideSpecifier> Parser::parseOverrideSpecifier()
{
solAssert(m_scanner->currentToken() == Token::Override, "");
ASTNodeFactory nodeFactory(*this);
std::vector<ASTPointer<UserDefinedTypeName>> 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<OverrideSpecifier>(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<ASTString>();
else if (_forceEmptyName || m_scanner->currentToken() == Token::LParen)
else if (_onlyFuncType || m_scanner->currentToken() == Token::LParen)
result.name = make_shared<ASTString>();
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<ASTNode> 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<ASTNode> Parser::parseFunctionDefinitionOrFunctionTypeStateVariable()
header.visibility,
header.stateMutability,
header.isConstructor,
header.overrides,
docstring,
header.parameters,
header.modifiers,
@ -637,6 +677,7 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(
}
bool isIndexed = false;
bool isDeclaredConst = false;
ASTPointer<OverrideSpecifier> overrides = nullptr;
Declaration::Visibility visibility(Declaration::Visibility::Default);
VariableDeclaration::Location location = VariableDeclaration::Location::Unspecified;
ASTPointer<ASTString> identifier;
@ -659,6 +700,13 @@ ASTPointer<VariableDeclaration> 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<VariableDeclaration> Parser::parseVariableDeclaration(
_options.isStateVariable,
isIndexed,
isDeclaredConst,
overrides,
location
);
}

View File

@ -71,6 +71,7 @@ private:
struct FunctionHeaderParserResult
{
bool isConstructor;
ASTPointer<OverrideSpecifier> overrides;
ASTPointer<ASTString> name;
ASTPointer<ParameterList> parameters;
ASTPointer<ParameterList> returnParameters;
@ -88,8 +89,9 @@ private:
ASTPointer<ContractDefinition> parseContractDefinition();
ASTPointer<InheritanceSpecifier> parseInheritanceSpecifier();
Declaration::Visibility parseVisibilitySpecifier();
ASTPointer<OverrideSpecifier> parseOverrideSpecifier();
StateMutability parseStateMutability();
FunctionHeaderParserResult parseFunctionHeader(bool _forceEmptyName, bool _allowModifiers);
FunctionHeaderParserResult parseFunctionHeader(bool _onlyFuncType, bool _allowFuncDef);
ASTPointer<ASTNode> parseFunctionDefinitionOrFunctionTypeStateVariable();
ASTPointer<FunctionDefinition> parseFunctionDefinition(ASTString const* _contractName);
ASTPointer<StructDefinition> parseStructDefinition();

View File

@ -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}}}

View File

@ -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,

View File

@ -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",

View File

@ -31,6 +31,7 @@
"id" : 3,
"name" : "i",
"nodeType" : "VariableDeclaration",
"overrides" : null,
"scope" : 4,
"src" : "13:8:1",
"stateVariable" : true,

View File

@ -1 +1,3 @@
contract C { uint[] i; }
// ----

View File

@ -40,6 +40,7 @@
{
"constant" : false,
"name" : "i",
"overrides" : null,
"scope" : 4,
"stateVariable" : true,
"storageLocation" : "default",

View File

@ -41,6 +41,7 @@
"modifiers" : [],
"name" : "",
"nodeType" : "FunctionDefinition",
"overrides" : null,
"parameters" :
{
"id" : 1,

View File

@ -2,3 +2,5 @@ contract C {
constructor() public {
}
}
// ----

View File

@ -47,6 +47,7 @@
null
],
"name" : "",
"overrides" : null,
"scope" : 5,
"stateMutability" : "nonpayable",
"superFunction" : null,

View File

@ -151,6 +151,7 @@
"modifiers" : [],
"name" : "fn",
"nodeType" : "FunctionDefinition",
"overrides" : null,
"parameters" :
{
"id" : 11,

View File

@ -15,3 +15,5 @@ contract C {
/** Some comment on mod.*/ modifier mod() { _; }
/** Some comment on fn.*/ function fn() public {}
}
// ----

View File

@ -114,6 +114,7 @@
null
],
"name" : "fn",
"overrides" : null,
"scope" : 15,
"stateMutability" : "nonpayable",
"superFunction" : null,

View File

@ -41,6 +41,7 @@
"modifiers" : [],
"name" : "",
"nodeType" : "FunctionDefinition",
"overrides" : null,
"parameters" :
{
"id" : 1,

View File

@ -2,3 +2,5 @@ contract C {
function() external payable {
}
}
// ----

View File

@ -47,6 +47,7 @@
null
],
"name" : "",
"overrides" : null,
"scope" : 5,
"stateMutability" : "payable",
"superFunction" : null,

View File

@ -41,6 +41,7 @@
"modifiers" : [],
"name" : "",
"nodeType" : "FunctionDefinition",
"overrides" : null,
"parameters" :
{
"id" : 1,

View File

@ -1,3 +1,5 @@
contract C {
function() external {}
}
// ----

View File

@ -47,6 +47,7 @@
null
],
"name" : "",
"overrides" : null,
"scope" : 5,
"stateMutability" : "nonpayable",
"superFunction" : null,

View File

@ -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,

View File

@ -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",

View File

@ -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,

View File

@ -1 +1,3 @@
contract c { function f() public { uint a = 2 + 3; } }
// ----

View File

@ -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",

View File

@ -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,

View File

@ -1 +1,3 @@
contract c { uint[] a; function f() public { uint[] storage b = a; } }
// ----

View File

@ -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",

View File

@ -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,

View File

@ -1 +1,3 @@
contract C { modifier M(uint i) { _; } function F() M(1) public {} }
// ----

View File

@ -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,

View File

@ -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,

View File

@ -1 +1,3 @@
contract C { modifier M(uint i) { _; } function F() M(1) public {} }
// ----

View File

@ -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,

View File

@ -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,

View File

@ -1 +1,3 @@
contract C { function f() public { var x = hex"ff"; } }
// ----

View File

@ -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",

View File

@ -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"
}

View File

@ -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) {}
}
// ----

View File

@ -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"
}

View File

@ -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,

View File

@ -1 +1,3 @@
contract c { function f() public { uint[] memory x; } }
// ----

View File

@ -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",

View File

@ -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,

View File

@ -1 +1,3 @@
contract c { function f() public { uint[][] memory rows; } }
// ----

View File

@ -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",

View File

@ -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,

View File

@ -1 +1,3 @@
contract C { function f() { var x = 2; x++; } }
// ----

View File

@ -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",

View File

@ -545,7 +545,6 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
"mutable",
"null",
"of",
"override",
"partial",
"promise",
"reference",

View File

@ -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.

View File

@ -0,0 +1,5 @@
contract X {
int public override testvar;
function test() internal override returns (uint256);
}
// ----

View File

@ -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 ')'

View File

@ -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);
}
// ----

View File

@ -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 ')'

View File

@ -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 ','

View File

@ -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'

View File

@ -0,0 +1,8 @@
contract A {
function foo() internal returns (uint256);
}
contract X {
int public override() testvar;
}
// ----
// ParserError: (93-94): Expected identifier but got ')'