Rubberduck: Set var=function() raises incompatible NotAnObject inspection

Created on 28 Aug 2019  路  4Comments  路  Source: rubberduck-vba/Rubberduck

Version 2.4.1.4881
OS: Microsoft Windows NT 10.0.18362.0, x64
Host Product: Microsoft Office x86
Host Version: 16.0.11901.20218
Host Executable: EXCEL.EXE

Error: To the variable 'PT1' of declared type 'EXCEL.EXE;Excel.PivotTable' a value is set assigned with the incompatible declared type 'NotAnObject'

Set PT1 = ResultsPT()
'...
Function ResultsPT() As PivotTable
bug feature-inspections inspection-false-positive

All 4 comments

Thanks for reporting this. I will have a look at it tonight.

I think I found the problem, but I will have to verify later.

In my last two PRs, I changed how part of the resolution of index expressions works and introduced a bug: the check that arguments are present was dropped in the part leading to the default member resolution. This leads to a default member resolution pointing to the default member returning a String, the name of the pivot table.

Should I be able to confirm my analysis later, there should be an easy fix.

@MDoerner does it enter the index expression pipeline with Set PT1 = ResultsPT instead of Set PT1 = ResultsPT()? The parentheses shouldn't be needed here, this looks like it could be an edge case.

This is not an edge case. Personally, I always add the parentheses to distinguish function calls from variables.

Moreover, the resolution was correct before my changes.

Was this page helpful?
0 / 5 - 0 ratings