microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
747 stars 245 forks source link

Object reference not set to an instance of an object #494

Closed AndriusAndrulevicius closed 7 years ago

AndriusAndrulevicius commented 7 years ago

I've created and installed an extension. Specified the new extension as dependency in app.json. Declared a variable to point to one of the codeunits in the published extension and when trying to use intellisense to get it's functions I'm getting the following error below:

Microsoft (R) AL Compiler version 0.7.12087 Copyright (C) Microsoft Corporation. All rights reserved

Success: The package is created. [Error - 3:56:16 PM] Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible. Processing of message 'textDocument/completion' failed with error: 'Object reference not set to an instance of an object.' StackTrace: at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.TypeSymbolExtensions.IsArray(ITypeSymbol type) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\KindsAndExtensions\TypeSymbolExtensions.cs:line 79 at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.VisitParameter(ParameterSymbol symbol) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 213 at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.AddParametersIfRequired(MethodSymbol symbol) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 344 at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplayVisitor.VisitMethod(MethodSymbol symbol) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplayVisitor.cs:line 335 at Microsoft.Dynamics.Nav.CodeAnalysis.SymbolDisplay.ToDisplayParts(ISymbol symbol, SemanticModel semanticModelOpt, Int32 positionOpt, SymbolDisplayFormat format, Boolean minimal) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\SymbolDisplay\SymbolDisplay.cs:line 106 at Microsoft.Dynamics.Nav.CodeAnalysis.Symbol.ToDisplayParts(SymbolDisplayFormat format) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Symbols\Symbol.cs:line 473 at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.SymbolCompletionItem.Create(String displayText, TextSpan span, IReadOnlyList1 symbols, Int32 contextPosition, Int32 descriptionPosition, String sortText, String insertionText, Nullable1 glyph, String filterText, Boolean preselect, SupportedPlatformData supportedPlatforms, Boolean isArgumentName, ImmutableDictionary2 properties, ImmutableArray1 tags, CompletionItemRules rules) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\SymbolCompletionItem.cs:line 63 at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItem(String displayText, String insertionText, Int32 position, List1 symbols, AbstractSyntaxContext context, TextSpan span, Boolean preselect, SupportedPlatformData supportedPlatformData) in C:\Agent\_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 111 at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItem(String displayText, String insertionText, Int32 position, List1 symbols, AbstractSyntaxContext context, TextSpan span, Dictionary2 invalidProjectMap, List1 totalProjects, Boolean preselect) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 106 at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.<>cDisplayClass5_0.b__3(IGrouping2 g) in C:\Agent\_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 47 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.CreateItems(Int32 position, IEnumerable1 symbols, TextSpan span, AbstractSyntaxContext context, Dictionary2 invalidProjectMap, List1 totalProjects, Boolean preselect) in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 44 at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.d14.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 193 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.AbstractSymbolCompletionProvider.d13.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\AbstractSymbolCompletionProvider.cs:line 173 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.CompletionServiceWithProviders.d24.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\CompletionServiceWithProviders.cs:line 368 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.Completion.CompletionServiceWithProviders.d17.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces\Completion\CompletionServiceWithProviders.cs:line 186 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.CompletionRequestHandler.d2.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\CompletionRequestHandler.cs:line 40 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Nav.EditorServices.Protocol.MessageProtocol.RequestHandlerBase`1.d1.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\MessageProtocol\GenericRequestHandlerBase.cs:line 23 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.d5.MoveNext() in C:\Agent_work\38\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:line 60

atoader commented 7 years ago

Hi! I will try to repro this issue. It would be great if you could provide a small sample that reproduces the crash as you did for issue #492.

atoader commented 7 years ago

I could not reproduce the crash on the latest internal build following your instructions.

AndriusAndrulevicius commented 7 years ago

I was using latest publicly available build. Do you still want me to provide a small sample or is it not needed anymore?

atoader commented 7 years ago

If you can provide a sample that repros, I would appreciate it greatly. Maybe the bug is somewhere else and this is just a symptom.

AndriusAndrulevicius commented 7 years ago

Here are the files to generate the error. All files except AA_TEST.al and app.json.2.txt are used to create first extension. AA_TEST.AL and app.json.2.txt are used to create a second one that has dependencies. Now if you would try to use variable LibrarySales in file AA_TEST.al to see the functions in the codeunit the error would be shown in OUTPUT window.

AA_TEST.al.txt AndriusAndrulevicius_AutomatedTesting_1.0.0.0.navx.txt app.json.2.txt app.json.txt COD70130440_LibraryRandom.al.txt COD70130509_LibrarySales.al.txt COD70131000_LibraryUtility.al.txt COD70131300_LibraryERM.al.txt SampleTest.al.txt

atoader commented 7 years ago

Thanks! I found the issue. It is caused by how we generate reference symbols and it only happens when you have a parameter to a procedure that is a complex type.