Skip to content

Unreachable case inspection does not understand enums #4119

@Inarion

Description

@Inarion

Consider

Option Explicit

Public Enum LogLevel
    TraceLevel = 0
    DebugLevel
    InfoLevel
    WarnLevel
    ErrorLevel
    FatalLevel
End Enum

Public Function LogLevelToString(ByVal level As LogLevel) As String

    Select Case level

        Case LogLevel.DebugLevel
            ' Reachable (as per inspection results)
            LogLevelToString = "DEBUG"

        Case LogLevel.ErrorLevel
            ' Unreachable (as per inspection results)
            LogLevelToString = "ERROR"

        Case LogLevel.FatalLevel
            ' Unreachable (as per inspection results)
            LogLevelToString = "FATAL"

        Case LogLevel.InfoLevel
            ' Unreachable (as per inspection results)
            LogLevelToString = "INFO"

        Case LogLevel.TraceLevel
            ' Reachable (as per inspection results)
            LogLevelToString = "TRACE"

        Case LogLevel.WarnLevel
            ' Unreachable (as per inspection results)
            LogLevelToString = "WARNING"

    End Select

End Function

As per my testing, every single case is reachable (i.e. produces the correct output string. Yet RD assumes most cases to be unreachable. (First case has value 1, and RD only deems the one case with value 0 as reachable. Every case with a higher value is considered unreachable.)

Version 2.2.6738.40126
OS: Microsoft Windows NT 6.1.7601 Service Pack 1, x64
Host Product: Microsoft Office 2010 x86
Host Version: 14.0.7197.5000
Host Executable: WINWORD.EXE
(switched to Word because there are no add-ins or other modules producing inspection noise)

Metadata

Metadata

Assignees

Labels

bugIdentifies work items for known bugscode-path-analysisInvolves simulating execution paths / interpreting the user code ..to an extent.difficulty-03-duckInvolves more challenging problems and/or developing within and revising the internals APIfeature-inspectionshas-workaroundThere is some way of working around this limitation / bug that is confirmed to workinspection-false-positiveA bug where an inspection result appears, even though it is incorrect.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions