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
744 stars 245 forks source link

Inconsistent behavior in the treatment of Label Capitalization (AA0137) #4360

Closed JavierFuentes closed 5 years ago

JavierFuentes commented 5 years ago

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

atoader commented 5 years ago

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

IvoMol commented 5 years ago

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)

atoader commented 5 years ago

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

IvoMol commented 5 years ago

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.

atoader commented 5 years ago

@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.

JavierFuentes commented 5 years ago

@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.

atoader commented 5 years ago

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

JavierFuentes commented 5 years ago

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