Skip to content

Commit

Permalink
fix: error reported with the same code twice
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse authored and nikola-matic committed Nov 25, 2022
1 parent 9070e2d commit 67057e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 13 additions & 10 deletions libsolidity/analysis/DeclarationTypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ void DeclarationTypeChecker::endVisit(Mapping const& _mapping)
{
auto childMappingType = dynamic_cast<MappingType const*>(valueType);
ASTString currentValueName = valueName;
bool isError = false;
while (true) {
// Value type is a mapping.
if (childMappingType)
Expand All @@ -292,11 +293,8 @@ void DeclarationTypeChecker::endVisit(Mapping const& _mapping)
ASTString childKeyName = childMappingType->keyName();
if (keyName == childKeyName)
{
m_errorReporter.declarationError(
1809_error,
_mapping.location(),
"Conflicting parameter name \"" + keyName + "\" in mapping."
);
isError = true;
break;
}
auto valueType = childMappingType->valueType();
currentValueName = childMappingType->valueName();
Expand All @@ -307,15 +305,20 @@ void DeclarationTypeChecker::endVisit(Mapping const& _mapping)
// Compare top mapping's key name with the value name.
if (keyName == currentValueName)
{
m_errorReporter.declarationError(
1809_error,
_mapping.location(),
"Conflicting parameter name \"" + keyName + "\" in mapping."
);
isError = true;
break;
}
break; // We arrived at the end of mapping recursion.
}
}
if (isError)
{
m_errorReporter.declarationError(
1809_error,
_mapping.location(),
"Conflicting parameter name \"" + keyName + "\" in mapping."
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ contract test {
// ----
// DeclarationError 1809: (45-84): Conflicting parameter name "owner" in mapping.
// DeclarationError 1809: (20-85): Conflicting parameter name "owner" in mapping.
// DeclarationError 1809: (20-85): Conflicting parameter name "owner" in mapping.

0 comments on commit 67057e6

Please sign in to comment.