mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #9703 from a3d4/fix-4558-shadowed-declaration-warning
Corrected warning for homonymous, but not shadowing declarations
This commit is contained in:
		
						commit
						74efd5ba46
					
				| @ -15,6 +15,7 @@ Compiler Features: | |||||||
| 
 | 
 | ||||||
| Bugfixes: | Bugfixes: | ||||||
|  * Type Checker: Disallow ``virtual`` for modifiers in libraries. |  * 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. |  * 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 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. |  * Type system: Fix named parameters in overloaded function and event calls being matched incorrectly if the order differs from the declaration. | ||||||
|  | |||||||
| @ -503,11 +503,20 @@ bool DeclarationRegistrationHelper::registerDeclaration( | |||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			auto shadowedLocation = shadowedDeclaration->location(); | 			auto shadowedLocation = shadowedDeclaration->location(); | ||||||
| 			_errorReporter.warning( | 
 | ||||||
| 				2519_error, | 			if (!shadowedDeclaration->isVisibleInContract()) | ||||||
| 				_declaration.location(), | 				_errorReporter.warning( | ||||||
| 				"This declaration shadows an existing declaration.", | 					8760_error, | ||||||
| 				SecondarySourceLocation().append("The shadowed declaration is here:", shadowedLocation) | 					_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(), | ||||||
|  | 					"This declaration shadows an existing declaration.", | ||||||
|  | 					SecondarySourceLocation().append("The shadowed declaration is here:", shadowedLocation) | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -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