mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove ReferencesResolver class-specific error reporting functions
This commit is contained in:
parent
3a75b1da4d
commit
66a8c7d1ab
@ -119,7 +119,7 @@ bool ReferencesResolver::visit(Identifier const& _identifier)
|
|||||||
else
|
else
|
||||||
errorMessage += " Did you mean " + std::move(suggestions) + "?";
|
errorMessage += " Did you mean " + std::move(suggestions) + "?";
|
||||||
}
|
}
|
||||||
declarationError(_identifier.location(), errorMessage);
|
m_errorReporter.declarationError(8051_error, _identifier.location(), errorMessage);
|
||||||
}
|
}
|
||||||
else if (declarations.size() == 1)
|
else if (declarations.size() == 1)
|
||||||
_identifier.annotation().referencedDeclaration = declarations.front();
|
_identifier.annotation().referencedDeclaration = declarations.front();
|
||||||
@ -157,7 +157,7 @@ void ReferencesResolver::endVisit(UserDefinedTypeName const& _typeName)
|
|||||||
Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath());
|
Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath());
|
||||||
if (!declaration)
|
if (!declaration)
|
||||||
{
|
{
|
||||||
fatalDeclarationError(_typeName.location(), "Identifier not found or not unique.");
|
m_errorReporter.fatalDeclarationError(7556_error, _typeName.location(), "Identifier not found or not unique.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,14 +209,14 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
|
|||||||
));
|
));
|
||||||
if (realName.empty())
|
if (realName.empty())
|
||||||
{
|
{
|
||||||
declarationError(_identifier.location, "In variable names _slot and _offset can only be used as a suffix.");
|
m_errorReporter.declarationError(9553_error, _identifier.location, "In variable names _slot and _offset can only be used as a suffix.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
declarations = m_resolver.nameFromCurrentScope(realName);
|
declarations = m_resolver.nameFromCurrentScope(realName);
|
||||||
}
|
}
|
||||||
if (declarations.size() > 1)
|
if (declarations.size() > 1)
|
||||||
{
|
{
|
||||||
declarationError(_identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported.");
|
m_errorReporter.declarationError(8827_error, _identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (declarations.size() == 0)
|
else if (declarations.size() == 0)
|
||||||
@ -224,7 +224,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
|
|||||||
if (auto var = dynamic_cast<VariableDeclaration const*>(declarations.front()))
|
if (auto var = dynamic_cast<VariableDeclaration const*>(declarations.front()))
|
||||||
if (var->isLocalVariable() && m_yulInsideFunction)
|
if (var->isLocalVariable() && m_yulInsideFunction)
|
||||||
{
|
{
|
||||||
declarationError(_identifier.location, "Cannot access local Solidity variables from inside an inline assembly function.");
|
m_errorReporter.declarationError(8477_error, _identifier.location, "Cannot access local Solidity variables from inside an inline assembly function.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
|
|||||||
|
|
||||||
string namePrefix = identifier.name.str().substr(0, identifier.name.str().find('.'));
|
string namePrefix = identifier.name.str().substr(0, identifier.name.str().find('.'));
|
||||||
if (isSlot || isOffset)
|
if (isSlot || isOffset)
|
||||||
declarationError(identifier.location, "In variable declarations _slot and _offset can not be used as a suffix.");
|
m_errorReporter.declarationError(8820_error, identifier.location, "In variable declarations _slot and _offset can not be used as a suffix.");
|
||||||
else if (
|
else if (
|
||||||
auto declarations = m_resolver.nameFromCurrentScope(namePrefix);
|
auto declarations = m_resolver.nameFromCurrentScope(namePrefix);
|
||||||
!declarations.empty()
|
!declarations.empty()
|
||||||
@ -252,7 +252,8 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
|
|||||||
for (auto const* decl: declarations)
|
for (auto const* decl: declarations)
|
||||||
ssl.append("The shadowed declaration is here:", decl->location());
|
ssl.append("The shadowed declaration is here:", decl->location());
|
||||||
if (!ssl.infos.empty())
|
if (!ssl.infos.empty())
|
||||||
declarationError(
|
m_errorReporter.declarationError(
|
||||||
|
6005_error,
|
||||||
identifier.location,
|
identifier.location,
|
||||||
ssl,
|
ssl,
|
||||||
namePrefix.size() < identifier.name.str().size() ?
|
namePrefix.size() < identifier.name.str().size() ?
|
||||||
@ -266,19 +267,4 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
|
|||||||
visit(*_varDecl.value);
|
visit(*_varDecl.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description)
|
|
||||||
{
|
|
||||||
m_errorReporter.declarationError(8532_error, _location, _description);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReferencesResolver::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _ssl, string const& _description)
|
|
||||||
{
|
|
||||||
m_errorReporter.declarationError(3881_error, _location, _ssl, _description);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description)
|
|
||||||
{
|
|
||||||
m_errorReporter.fatalDeclarationError(6546_error, _location, _description);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,15 +88,6 @@ private:
|
|||||||
void operator()(yul::Identifier const& _identifier) override;
|
void operator()(yul::Identifier const& _identifier) override;
|
||||||
void operator()(yul::VariableDeclaration const& _varDecl) override;
|
void operator()(yul::VariableDeclaration const& _varDecl) override;
|
||||||
|
|
||||||
/// Adds a new error to the list of errors.
|
|
||||||
void declarationError(langutil::SourceLocation const& _location, std::string const& _description);
|
|
||||||
|
|
||||||
/// Adds a new error to the list of errors.
|
|
||||||
void declarationError(langutil::SourceLocation const& _location, langutil::SecondarySourceLocation const& _ssl, std::string const& _description);
|
|
||||||
|
|
||||||
/// Adds a new error to the list of errors and throws to abort reference resolving.
|
|
||||||
void fatalDeclarationError(langutil::SourceLocation const& _location, std::string const& _description);
|
|
||||||
|
|
||||||
langutil::ErrorReporter& m_errorReporter;
|
langutil::ErrorReporter& m_errorReporter;
|
||||||
NameAndTypeResolver& m_resolver;
|
NameAndTypeResolver& m_resolver;
|
||||||
langutil::EVMVersion m_evmVersion;
|
langutil::EVMVersion m_evmVersion;
|
||||||
|
Loading…
Reference in New Issue
Block a user