Rubberduck icon indicating copy to clipboard operation
Rubberduck copied to clipboard

Resolver Error

Open phobo3s opened this issue 3 years ago • 5 comments

Rubberduck version information Version 2.5.2.6059 OS: Microsoft Windows NT 10.0.19044.0, x64 Host Product: Microsoft Office x86 Host Version: 16.0.14931.20132 Host Executable: EXCEL.EXE

Before anything i must say that it is the perfect project for my work. I am an civil engineer and i develop small apps for my work. as you can guess there is not much collaboration on the subject.

Description I have build an custom add-in for my work. there is plenty of things inside. Many different little procedures. When i loaded my add-in and opened VBE editor, i get the resolver error and i can't use rubberduck.

To Reproduce 1.Load my add-in 2.Press Alt+F11

Expected behavior Expecting the resolving attempt to be completed.

Logfile

https://github.com/rubberduck-vba/Rubberduck/files/8364209/RubberduckLog.txt

phobo3s avatar Mar 28 '22 14:03 phobo3s

Please upload the entire log to your original post. There may be things beyond what you're noting that impact the error.

daFreeMan avatar Mar 28 '22 14:03 daFreeMan

added log file.

phobo3s avatar Mar 28 '22 15:03 phobo3s

Looks like the core problem is here:

2022-03-28 18:32:11.5777;INFO-2.5.2.6059;Rubberduck.Parsing.Common.ParsingStageTimer;Added supertypes for document modules in 0ms.;
2022-03-28 18:32:12.0764;WARN-2.5.2.6059;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type __MIDL_IWinTypes_0003;
2022-03-28 18:32:12.1004;WARN-2.5.2.6059;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type __MIDL_IWinTypes_0009;
2022-03-28 18:32:12.1004;WARN-2.5.2.6059;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type __MIDL_IWinTypes_0007;
2022-03-28 18:32:12.1004;WARN-2.5.2.6059;Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass;Failed to resolve type __MIDL_IWinTypes_0003;
2022-03-28 18:32:12.1163;ERROR-2.5.2.6059;Rubberduck.Parsing.VBA.ReferenceManagement.ReferenceResolveRunnerBase;Exception thrown on resolving those modules: 'TheBerk.ZWCADSubs,TheBerk.ARGE,TheBerk.CustomMenu,TheBerk.BClean,TheBerk.UsefullSubs,TheBerk.Functiones,TheBerk.BuÇalışmaKitabı,TheBerk.UserForm1,TheBerk.ApiCalls,TheBerk.NumberSplitterInputForm,TheBerk.ShortCuts,TheBerk.Keyboards' (thread 16).;System.NullReferenceException: Nesne başvurusu bir nesnenin örneğine ayarlanmadı.
   konum: Rubberduck.Parsing.Symbols.Declaration.set_AsTypeDeclaration(Declaration value)
   konum: Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass.AnnotateType(Declaration declaration)
   konum: Rubberduck.Parsing.VBA.ReferenceManagement.CompilationPasses.TypeAnnotationPass.Execute(IReadOnlyCollection`1 modules)
   konum: Rubberduck.Parsing.VBA.ReferenceManagement.ReferenceResolveRunnerBase.<>c__DisplayClass12_0.<ExecuteCompilationPasses>b__0(ICompilationPass p)
   konum: System.Collections.Generic.List`1.ForEach(Action`1 action)
   konum: Rubberduck.Parsing.VBA.ReferenceManagement.ReferenceResolveRunnerBase.ExecuteCompilationPasses(IReadOnlyCollection`1 modules, CancellationToken token)
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'ZWCADSubs' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'UsefullSubs' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'Functiones' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'BuÇalışmaKitabı' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'UserForm1' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'ARGE' state is changing to 'ResolverError' (thread 15);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'CustomMenu' state is changing to 'ResolverError' (thread 17);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'Keyboards' state is changing to 'ResolverError' (thread 17);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'BClean' state is changing to 'ResolverError' (thread 7);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'ApiCalls' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'NumberSplitterInputForm' state is changing to 'ResolverError' (thread 16);
2022-03-28 18:32:12.1163;DEBUG-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;Module 'ShortCuts' state is changing to 'ResolverError' (thread 15);
2022-03-28 18:32:12.1263;INFO-2.5.2.6059;Rubberduck.Parsing.VBA.RubberduckParserState;RubberduckParserState (20) is invoking StateChanged (ResolverError);
2022-03-28 18:32:12.1263;TRACE-2.5.2.6059;Rubberduck.UI.Command.MenuItems.CommandBars.AppCommandBarBase;CancellationTokenSource was already disposed for OnParserStateChanged.;
2022-03-28 18:32:12.1263;INFO-2.5.2.6059;Rubberduck.Parsing.Common.ParsingStageTimer;Executed compilation passes in 0ms.;

mburns08109 avatar Apr 07 '22 18:04 mburns08109

I think the following line is to blame. https://github.com/rubberduck-vba/Rubberduck/blob/a07fcac6b06b6fafcfb3e9a6065efc504a11e3ad/Rubberduck.Parsing/Symbols/Declaration.cs#L532 That blows up if the value assigned as AsTypeDeclaration is null. I guess we just have to add a ? on the member access. Maybe I can get to it this weekend.

MDoerner avatar Apr 07 '22 20:04 MDoerner

am i have to change my variable declarations?

phobo3s avatar Jun 08 '22 06:06 phobo3s

The PR above will quite certainly remove the resolver error. However, it is not clear to me how we could end up with a null there given how we parse. This should only ever be the AsTypeDeclaration for built-in types and the corresponding array types. However, them turning up here is somewhat unexpected. Accordingly, it would be interesting to know what kind of test was used after As in the declarations in the failed modules.

Moreover, I would be interested if there remain additional follow up problems after the symptomatic fix has been merged. Accordingly, the PR will not automatically close this bug.

MDoerner avatar Oct 07 '22 14:10 MDoerner

thank you. i dind't understand half of the things you said but it is solved. there is no parse error left. i think because of this error is early binding.

phobo3s avatar Oct 14 '22 07:10 phobo3s

Good to hear the fix worked.

Could you show us some examples of the types (more precisely the text after As) you used for the variable declarations in one of the modules previously affected by the bug, e.g. from TheBerk.ZWCADSubs? That would help us to understand how we ended up in the unexpected code path?

MDoerner avatar Oct 14 '22 08:10 MDoerner

Dim isZwCad As Boolean
Dim zcadApp As Object
Dim zcadDoc As Object
On Error Resume Next
Set zcadApp = GetObject(, "ZWCAD.Application")
'if no zwcad then try autocad
If zcadApp Is Nothing Then
    Set zcadApp = GetObject(, "AutoCAD.Application.23")
    isZwCad = False
    If zcadApp Is Nothing Then Exit Sub
Else
    isZwCad = True
End If

I think this is the type of declaration that causes the error.

phobo3s avatar Oct 15 '22 06:10 phobo3s