Al: Inconsistent behavior in the treatment of Label Capitalization (AA0137)

Created on 15 Dec 2018  路  8Comments  路  Source: microsoft/AL

Describe the bug
If you declare a Label, AL Compiler shows an AA0137 warning of not used variable when you use it with a different capitalization.

To Reproduce
See the screenshot image.

Expected behavior
Compiler should guarantee and automatically convert all Variables, Labels, FieldNames, etc to its original declaration format to make the code more readable, consistent and cleaner.

Once this functionality was implemented, these false notifications should no longer appear.

Screenshots
image

Versions:
AL Language: 2.0.48254
Business Central: ES Dynamics NAV 13.0 (24630) OnPremise

bug ships-in-future-update

Most helpful comment

codeunit 50101 "Test AA0137"
{
trigger OnRun()
var
myInt1: Integer;
begin
end;

var
    myInt: Integer;

}

PROBLEMS:
Variable 'myInt1' is unused in the method 'OnRun'.

EXPECTED:
Variable 'myInt1' is unused in the method 'OnRun'.
Variable 'myInt' is unused.

All 8 comments

Hi @JavierFuentes ! Nice catch! This is a bug in the CodeCop analyzer.

Please check rule AA0137 with global varibles too.
It looks like it does not work at all. Thank you.

AL Language: 2.1.69331.
Business Central: 13.2.26556.0 (On-Premises)

@IvoMol please provide a repo with expected output and actual output.

codeunit 50101 "Test AA0137"
{
trigger OnRun()
var
myInt1: Integer;
begin
end;

var
    myInt: Integer;

}

PROBLEMS:
Variable 'myInt1' is unused in the method 'OnRun'.

EXPECTED:
Variable 'myInt1' is unused in the method 'OnRun'.
Variable 'myInt' is unused.

@IvoMol your code seems to be working as expected in the master version. You should expect both fixes to be available with the next release of the AL language extension.

@atoader,
please consider my suggestion at #416 too for enclose variable declarations with optionals { ... } or var ... endvar blocks because without this block tags, the BC code has poor readability when there are a large number of declared global variables.

@JavierFuentes you should create a separate issue for this suggestion. That way other developers get a chance to vote on the issue.

Hi @atoader,
I've added a new comment on #63

Was this page helpful?
0 / 5 - 0 ratings