Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

False positive on inspection "Variable is used but not assigned." when initial assignment is with ReDim. #6282

Copy link
Copy link
@pricerc

Description

@pricerc
Issue body actions

Rubberduck version information

Rubberduck Version 2.5.9.6316
OS: Microsoft Windows NT 10.0.19045.0, x64
Host Product: Microsoft Office x86
Host Version: 16.0.18925.20168
Host Executable: EXCEL.EXE

Description
I'm getting a "False positive" on inspection "Variable is used but not assigned."

Seemingly when the initial assignment is with ReDim.

To Reproduce
I have a number of module-level arrays that get initialized as part of an 'upload' process with the push of a button.

e.g.

    ' Read INVSSTFields table
    rowCount = invsstTable.DataBodyRange.Rows.Count
    ReDim m_INVSSTFieldInfo(0 To rowCount - 1, 0 To 4) ' FieldName, Type, Length, Required, Format
    Dim invsstKeyCount As Long: invsstKeyCount = 0
    For i = 1 To rowCount
        m_INVSSTFieldInfo(i - 1, 0) = invsstTable.DataBodyRange.Cells(i, invsstTable.ListColumns("FieldName").Index).value
        m_INVSSTFieldInfo(i - 1, 1) = invsstTable.DataBodyRange.Cells(i, invsstTable.ListColumns("Type").Index).value
        m_INVSSTFieldInfo(i - 1, 2) = invsstTable.DataBodyRange.Cells(i, invsstTable.ListColumns("Length").Index).value
        m_INVSSTFieldInfo(i - 1, 3) = invsstTable.DataBodyRange.Cells(i, invsstTable.ListColumns("Required").Index).value
        m_INVSSTFieldInfo(i - 1, 4) = invsstTable.DataBodyRange.Cells(i, invsstTable.ListColumns("Format").Index).value
    Next i

If I initialize m_INVSSTFieldInfo with m_INVSSTFieldInfo = vbNullString, then the inspection is happy.

Additional context
I've been using a combination of AI and RubberDuck to get some interesting work done. Thank-you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentifies work items for known bugsIdentifies work items for known bugscode-path-analysisInvolves simulating execution paths / interpreting the user code ..to an extent.Involves simulating execution paths / interpreting the user code ..to an extent.resolverIssue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.