AL icon indicating copy to clipboard operation
AL copied to clipboard

Spurious syntax errors when adding conditions to FlowField CalcFormula expression: "'FIELD', 'CONST' or 'FILTER' keyword is expected."

Open dzzzb opened this issue 5 years ago • 2 comments

Describe the bug Prepending a new condition to a FlowField's CalcFormula results in a false syntax error, and I have to then go and re-type a different part of the pre-existing code to dismiss that.

To Reproduce

  1. Have a FlowField with a CalcFormula containing 1 (or more) condition(2)
  2. Go to just after the where(, type a space, then go before that, and add a new condition (having the space after means Intellisense works, etc.)
  3. Observe the spurious errors reported:
'FIELD', 'CONST' or 'FILTER' keyword is expected. AL(AL0292) [17, 78]
Syntax error, ')' expected AL(AL0104) [17, 83]
Syntax error, ')' expected AL(AL0104) [17, 83]

minimal sample:

table 50100 Foo
{
    fields
    {
        field(1; "Entry No."; Integer)
        {
        }

        field(2; "Customer No."; Code[20])
        {
        }

        field(3; "No. of Customers"; Integer)
        {
            FieldClass = FlowField;
            Editable = false;
            CalcFormula = count(Customer where("No." = field("Customer No.")));
            // Edit the above to add the following and observe: Blocked = const(" "), 
            // CalcFormula = count(Customer where(Blocked = const(" "), "No." = field("Customer No.")));
        }
    }

    keys
    {
        key(PK; "Entry No.")
        {
            Clustered = true;
        }
    }
}

Expected behavior This is yet another waste of developers' time, where the background/realtime code analysis fires errors that aren't really errors, and we have to re-enter/cut/paste/whatever the same code just to get rid of those wrongly reported errors.

See also e.g. #6225, #6232, #6276

Screenshots

This is the exact scenario where I first noticed this bug.

Original code before adding condition: image

after adding condition, reporting spurious error: image

after fixing said error by deleting and retyping the 'offending' field keyword... image

This is the same false error with the minimal code given above: image

after retyping field: image

5. Versions:

  • AL Language: 6.1.362735
  • Business Central: n/a

dzzzb avatar Dec 01 '20 13:12 dzzzb

just to confirm, can still replicate (although I'm not sure it happens every time the new field is added, or for every conceivable way it can be typed)

image

dzzzb avatar Jun 15 '21 14:06 dzzzb

I am having this same issue version, started happening after addition TooltipML condition to fields which already existed in the project

HBPGroupPreSales avatar Oct 18 '23 08:10 HBPGroupPreSales