Fix shadowing error for inline assembly.

This commit is contained in:
chriseth
2021-08-17 12:12:56 +02:00
parent 838514a718
commit aeb2438eab
25 changed files with 67 additions and 56 deletions
+16 -20
View File
@@ -274,28 +274,8 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
{
for (auto const& identifier: _varDecl.variables)
{
validateYulIdentifierName(identifier.name, identifier.debugData->location);
if (
auto declarations = m_resolver.nameFromCurrentScope(identifier.name.str());
!declarations.empty()
)
{
SecondarySourceLocation ssl;
for (auto const* decl: declarations)
ssl.append("The shadowed declaration is here:", decl->location());
if (!ssl.infos.empty())
m_errorReporter.declarationError(
3859_error,
identifier.debugData->location,
ssl,
"This declaration shadows a declaration outside the inline assembly block."
);
}
}
if (_varDecl.value)
visit(*_varDecl.value);
}
@@ -385,4 +365,20 @@ void ReferencesResolver::validateYulIdentifierName(yul::YulString _name, SourceL
_location,
"The identifier name \"" + _name.str() + "\" is reserved."
);
auto declarations = m_resolver.nameFromCurrentScope(_name.str());
if (!declarations.empty())
{
SecondarySourceLocation ssl;
for (auto const* decl: declarations)
if (decl->location().hasText())
ssl.append("The shadowed declaration is here:", decl->location());
if (!ssl.infos.empty())
m_errorReporter.declarationError(
3859_error,
_location,
ssl,
"This declaration shadows a declaration outside the inline assembly block."
);
}
}