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

"Possible overflow assigning 'xxx' to 'yyy'" not triggered in Get procedure #5108

Closed Nyryus closed 2 years ago

Nyryus commented 5 years ago

The CodeCop doesn't show a warning when we use a text variable that is bigger than the field, in the get procedure.

Codeunit 50100 MyCodeunit
{
    trigger OnRun()
    var
        TestTable: Record "Test Table";
    begin
        TestTable.Get(1, Text200);
        TestTable.Get(1, Text250);

        TestTable.TextField := Text250;
        TestTable.TextField := Text200;
    end;

    var
        Text250: Text[250];
        Text200: Text[200];
}

table 50100 "Test Table"
{
    fields
    {
        field(1; IntField; Integer)
        {
            DataClassification = CustomerContent;
        }
        field(2; TextField; Text[200])
        {
            DataClassification = CustomerContent;
        }
    }

    keys
    {
        key(PK; IntField, TextField)
        {
            Clustered = true;
        }
    }
} 

I expect that the Get with Text250, warn me of a possible overflow.

immagine

mazhelez commented 2 years ago

Thank you for reporting this. However, we do not see an actual issue here as the Get would simply not succeed if the variable has more characters than the field.