Shadowed Declaration

Identifies identifiers that hide/"shadow" other identifiers otherwise accessible in that scope.

 NEW! This inspection is only available in pre-release builds.


Global namespace contains a number of perfectly legal identifier names that user code can use. But using these names in user code effectively "hides" the global ones. In general, avoid shadowing global-scope identifiers if possible.

Default severity


Inspection type



This example should trigger a result

MyModule (StandardModule)
Private MsgBox As String ' hides the global-scope VBA.Interaction.MsgBox function in this module. Public Sub DoSomething() MsgBox = "Test" ' refers to the module variable in scope. VBA.Interaction.MsgBox MsgBox ' global function now needs to be fully qualified to be accessed. End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Private message As String Public Sub DoSomething() message = "Test" MsgBox message ' VBA.Interaction module qualifier is optional. End Sub

Rubberduck.CodeAnalysis.Inspections.Concrete.ShadowedDeclarationInspection.cs (Prerelease-v2.5.2.6174)