Al: Rule137DoNotDeclareVariablesThatAreUnused Index out of range error

Created on 30 Nov 2018  路  10Comments  路  Source: microsoft/AL

After I have installed the AL Language 2.0.56865 extension I am seeing this warning in the Problems list in VS Code (1.29.1)

Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule137DoNotDeclareVariablesThatAreUnused' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'

This is the full message information:

{
"resource": "../app.json",
"owner": "_generated_diagnostic_collection_name_#0",
"code": "AD0001",
"severity": 4,
"message": "Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule137DoNotDeclareVariablesThatAreUnused' threw an exception of type 'System.IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'",
"source": "AL",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1
}

bug ships-in-future-update

All 10 comments

Not surprisingly that removing the ${CodeCop} analyzer makes the warning go away. However, I prefer to leave this on.

Hi @GreatScott000, can you provide a small AL sample which reproduces this issue? Thanks!

@JohanStenberg100 I can do that for you but it will not be until 2018/12/04

Hi, @GreatScott000 , @JohanStenberg100

I've also been getting this warning from quite a while, but up until today I didn't have the time to try to pinpoint what was causing it (we got the warning in two big projects). After doing some tests, I've managed to reproduce the error by following these steps:

  1. Create a new AL project.
  2. Configure the launch.json file and download symbols.
  3. Add the following codeunit:
codeunit 50100 "Test"
{
    TableNo = "Job Queue Entry";

    trigger OnRun()
    begin
    end;
}

Tested using VS Code 1.29.1 + AL extension 2.0.56865 + Docker with version 13.1.25940.26323 (ES)

Ooops: and obviously, between steps 1 and 3, enable the code analyzers! (I have both AppSourceCop and CodeCop enabled)

@salgiza thank you, this exception does not reproduce on our master branch but I can reproduce it on the 2.0.56865 version. Make sure to update when a new AL VS code extension version is out. @GreatScott000 please post your repro as well so I can verify it's the same root cause.

@GreatScott000 I'm now assuming you have the same issue as salgiza.

@JohanStenberg100 I apologize. I am in the middle of a big implementation and have not been able to get back to this. I do not have have a clear repro scenario to. Let's assume that my issue is the same and work from there.

@GreatScott000 no problem. Make sure to try the new extension when it is released and open another issue if the issue still reproduces. Thanks!

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 26627.

If you don鈥檛 have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read:
https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/
https://blogs.msdn.microsoft.com/freddyk/2018/04/16/which-docker-image-is-the-right-for-you/

Was this page helpful?
0 / 5 - 0 ratings