Version 2.5.9.6319
OS: Microsoft Windows NT 10.0.19045.0, x64
Host Product: Microsoft Office x64
Host Version: 16.0.17029.20140
Host Executable: EXCEL.EXE
For demonstration use this Module code:
Private myObjectArray() As Object
Public Property Get ObjectArray() As Object()
ObjectArray = myObjectArray
End Property
Public Sub Test()
Dim oArr1(0) As Object
Set oArr1(0) = ThisWorkbook
myObjectArray = oArr1
Dim oArr2() As Object
oArr2 = ObjectArray
Debug.Print oArr2(0).Name
End Sub
Description
This code compiles and runs.
Rubberduck gives me 3 Code Inspection Errors:
Return value for member 'ObjectArray' is never assigned.
This refers to line Public Property Get ObjectArray() As Object()
Object variable 'ObjectArray' is assigned without the 'Set' keyword.
This refers to line ObjectArray = myObjectArray
In a context that requires a value type, the expression 'ObjectArray' of object type 'Object()' is used that does not have a suitable default member.
This refers to line oArr2 = ObjectArray and may be related to #6094
If I use the 'Set' keyword in front of ObjectArray = myObjectArray and in front of oArr2 = ObjectArray Rubberduck is satisfied and does not report any errors. But it does not compile, of course.
The inspection results are all consistent with the object array being mistakenly resolved as an object type; something somewhere is missing a check against Declaration.IsArray 🫤
Version 2.5.9.6319 OS: Microsoft Windows NT 10.0.19045.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.17029.20140 Host Executable: EXCEL.EXE
For demonstration use this Module code:
Description This code compiles and runs. Rubberduck gives me 3 Code Inspection Errors:
Public Property Get ObjectArray() As Object()
ObjectArray = myObjectArray
oArr2 = ObjectArray
and may be related to #6094If I use the 'Set' keyword in front of
ObjectArray = myObjectArray
and in front ofoArr2 = ObjectArray
Rubberduck is satisfied and does not report any errors. But it does not compile, of course.