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
737 stars 243 forks source link

FlowFields using themselves in CalcFormula should be a compile error, not runtime #6485

Open dzzzb opened 3 years ago

dzzzb commented 3 years ago

The below code compiles without warning but, of course, fails at runtime with this message:

There is insufficient memory to execute this function. This can be caused by recursive function calls. Contact your system administrator.

Such an unfortunate typo should be caught at compile time, rather than only being reported at runtime because it causes infinite recursion.

image

dzzzb commented 2 years ago

To confirm, this still doesn't error at design-time, which it should. And here's the code since who wants to type that all out:

tableextension 50100 CustomerExt extends Customer
{
    fields
    {
        field(50100; "Customer Posting Group Desc."; Text[100])
        {
            Caption = 'Customer Posting Group Desc.';
            FieldClass = FlowField;
            Editable = false;
            CalcFormula = lookup("Customer Posting Group".Description where("Code" = field("Customer Posting Group Desc.")));
        }
    }
}

image

Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 8.2.550913
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al