Correct the warning for homonymous, but not shadowing declarations

This commit is contained in:
a3d4 2020-08-30 20:37:43 +02:00
parent 4d470cd285
commit 4ca7655b74
4 changed files with 27 additions and 5 deletions

View File

@ -14,6 +14,7 @@ Compiler Features:
Bugfixes:
* Type Checker: Disallow ``virtual`` for modifiers in libraries.
* Type Checker: Correct the warning for homonymous, but not shadowing declarations.
* ViewPureChecker: Prevent visibility check on constructors.
* Type system: Fix internal error on implicit conversion of contract instance to the type of its ``super``.
* Type system: Fix named parameters in overloaded function and event calls being matched incorrectly if the order differs from the declaration.

View File

@ -503,6 +503,15 @@ bool DeclarationRegistrationHelper::registerDeclaration(
else
{
auto shadowedLocation = shadowedDeclaration->location();
if (!shadowedDeclaration->isVisibleInContract())
_errorReporter.warning(
8760_error,
_declaration.location(),
"This declaration has the same name as another declaration.",
SecondarySourceLocation().append("The other declaration is here:", shadowedLocation)
);
else
_errorReporter.warning(
2519_error,
_declaration.location(),

View File

@ -0,0 +1,6 @@
contract test {
function e() external { }
function f() public pure { uint e; e = 0; }
}
// ----
// Warning 8760: (77-83): This declaration has the same name as another declaration.

View File

@ -0,0 +1,6 @@
function e() {}
contract test {
function f() pure public { uint e; e = 0; }
}
// ----
// Warning 2519: (63-69): This declaration shadows an existing declaration.