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

AA0205 is fired for assigned variables when combined with THIS keyword - wrong close reason #7898

Open TKapitan opened 2 weeks ago

TKapitan commented 2 weeks ago

Please include the following with each issue:

1. Describe the bug AA0205 is fired for assigned variables when combined with THIS keyword

2. To Reproduce Steps to reproduce the behavior:

codeunit 71698222 FS5A23Test
{
    var
        HeaderTableNo, LineTableNo : Integer;

    procedure Proc1(EDIMessageType: Enum FS5A23EDIMessageType)
    begin
        Populate(this.HeaderTableNo, this.LineTableNo);
    end;

    procedure Proc2()
    begin
        Message(Format(this.HeaderTableNo + this.LineTableNo));
    end;

    local procedure Populate(var Variable1: Integer; var Variable2: Integer)
    begin
        Variable1 := 1;
        Variable2 := 2;
    end;
}

3. Expected behavior Warning should not be shown. The warning now disappear when you change Populate(this.HeaderTableNo, this.LineTableNo) to Populate(HeaderTableNo, LineTableNo) so it's probably related to THIS keyword and how the pass-by-reference is evaluated.

4. Actual behavior AA0205 warning is shown

5. Versions:

Internal work item: AB#557596

TKapitan commented 2 weeks ago

@nndobrev This was closed in #7886 as duplicate of #7877. However, this is not the same issue and has different impacts (I was discussing this issue at Directions on Thursday).

The linked issue is a problem with local/global variables. My issue is about a warning even when you have ONLY global variables. While I agree with the "by design" for #7877, my issue is not by design but an issue that will block anyone from using THIS keyword (as this warning is shown every time you pass this.VARIABLE to the setter.