mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Correct the warning for homonymous, but not shadowing declarations
This commit is contained in:
parent
4d470cd285
commit
4ca7655b74
@ -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.
|
||||
|
@ -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(),
|
||||
|
@ -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.
|
6
test/libsolidity/syntaxTests/scoping/name_shadowing2.sol
Normal file
6
test/libsolidity/syntaxTests/scoping/name_shadowing2.sol
Normal 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.
|
Loading…
Reference in New Issue
Block a user