← Back to Benchmark Results

gemini/gemini-3-pro-preview

62.5%
Pass Rate
35/56
Tasks Passed
3
Runs
54.8%
pass@1
62.5%
pass@3
87.5%
Consistency
0.1
Temperature
-
Thinking
2,488,457
Tokens
$3.11
Cost
1st: 872nd: 5Failed: 2135/56 passed

Known Shortcomings (23)

Sorted by occurrence count (most frequent first)

# Concept AL Concept Count Affected Tasks
1 codeunit-syntax-structure codeunit-definition 3 CG-AL-M005, CG-AL-E052, CG-AL-E051

Description: The model generated AL code with syntax errors - specifically missing 'end', ';', and '}' tokens at line 106. This indicates the model failed to properly structure the codeunit with correct AL syntax, likely producing malformed procedure bodies, incomplete begin/end blocks, or incorrect nesting. The generated code was not found/empty in the provided output, but the compilation errors at a specific line (106) with multiple syntax expectations suggest the model produced code that was structurally incomplete or had mismatched begin/end pairs. This is a fundamental AL syntax knowledge gap where the model couldn't produce a syntactically valid codeunit with multiple procedures involving HttpClient, JsonObject, and error handling patterns.

Correct Pattern:
codeunit 70002 "External Payment Service"
{
    procedure SendPaymentRequest(OrderId: Text; Amount: Decimal; Currency: Text; var ResponseJson: JsonObject): Boolean
    var
        Client: HttpClient;
        RequestMessage: HttpRequestMessage;
        ResponseMessage: HttpResponseMessage;
        Content: HttpContent;
        RequestJson: JsonObject;
        ResponseText: Text;
    begin
        // Build request, send via HttpClient, parse response
        // Proper begin/end blocks with error handling
        exit(false);
    end;

    procedure ValidatePaymentResponse(Response: JsonObject): Boolean
    var
        Token: JsonToken;
        StatusText: Text;
    begin
        if not Response.Get('status', Token) then
            exit(false);
        if not Response.Get('transactionId', Token) then
            exit(false);
        if not Response.Get('amount', Token) then
            exit(false);
        Response.Get('status', Token);
        StatusText := Token.AsValue().AsText();
        exit(StatusText = 'approved');
    end;

    // ... remaining procedures with proper begin/end structure
}
Incorrect Pattern:
// Generated code not available but compilation failed at line 106 with syntax errors expecting 'end', ';', and '}'

Error Codes: AL0104, AL0111

2 multiline-string-literals al-string-syntax 1 CG-AL-E050

Description: The model attempted to use backtick (`) characters for multiline string literals, likely borrowing syntax from other languages like JavaScript or Python. AL does not support backtick-delimited strings. In AL, multiline text must be constructed either using string concatenation with CR/LF characters, or using the newer AL multiline string literal syntax (available in newer BC versions) which uses single quotes with line breaks inside them. The compilation errors at line 13 with 'Unexpected character `' clearly indicate the model used backtick syntax which is invalid in AL.

Correct Pattern:
Use AL string concatenation with CR/LF characters, e.g.:
var CrLf: Text[2];
begin
  CrLf[1] := 13;
  CrLf[2] := 10;
  exit('SELECT CustomerNo, Name, Balance' + CrLf + 'FROM Customer' + CrLf + 'WHERE Active = true' + CrLf + 'ORDER BY Name');
end;

Or if the runtime supports it, use the AL multiline text constant syntax with single quotes spanning multiple lines.
Incorrect Pattern:
` (backtick-based multiline string literal attempt)

Error Codes: AL0183

3 inherent-permissions-syntax codeunit-properties 1 CG-AL-H019

Description: The model generated incorrect values for InherentEntitlements and InherentPermissions properties. The task specifies 'X' for both, which means Execute. However, the model likely wrote something like 'codeunit "CG Internal Service" = X' or used 'codeunit' as a permission value instead of the correct syntax. The valid values for InherentEntitlements and InherentPermissions are permission sets like 'X' (Execute), 'R' (Read), 'RIMD' etc., not object type references. The AL0776 error 'The identifier codeunit is not a valid permission value' indicates the model confused the property syntax, possibly writing something like 'InherentPermissions = codeunit 70019 = X' instead of simply 'InherentPermissions = X'.

Correct Pattern:
InherentEntitlements = X;
    InherentPermissions = X;
Incorrect Pattern:
InherentEntitlements = codeunit = X
    InherentPermissions = codeunit = X

Error Codes: AL0776

4 query-crossjoin-column-datasource query-object-definition 1 CG-AL-H017

Description: The model failed to generate any valid code (generated code not found), and when it did attempt generation, it produced a query where a Column did not have a valid data source or the Method property set to Count. In AL query objects with CrossJoin, the second dataitem is not nested under the first but is at the same level, and columns must correctly reference their parent dataitem's fields. The model likely struggled with the complex query structure involving CrossJoin between two instances of the same table ('Dimension Value'), proper column-to-dataitem binding, and the LeftOuterJoin with a Count method column. The AL0353 error at line 42 indicates a column was defined without properly referencing a source field from its parent dataitem.

Correct Pattern:
query 70017 "CG Dimension Matrix"
{
    QueryType = Normal;

    elements
    {
        dataitem(DeptDimValue; "Dimension Value")
        {
            SqlJoinType = CrossJoin;
            DataItemTableFilter = "Dimension Code" = const('DEPARTMENT');
            column(DepartmentCode; "Code") { }
            column(DepartmentName; Name) { }
            dataitem(ProjDimValue; "Dimension Value")
            {
                SqlJoinType = CrossJoin;
                DataItemTableFilter = "Dimension Code" = const('PROJECT');
                column(ProjectCode; "Code") { }
                column(ProjectName; Name) { }
                dataitem(DimSetEntry; "Dimension Set Entry")
                {
                    SqlJoinType = LeftOuterJoin;
                    DataItemLink = "Dimension Code" = DeptDimValue."Dimension Code";
                    column(MatchCount; "Entry No.")
                    {
                        Method = Count;
                    }
                }
            }
        }
    }
}
Incorrect Pattern:
// Generated code not found - model failed to produce valid output

Error Codes: AL0353

5 complete-codeunit-generation recordref-fieldref-dynamic-manipulation 1 CG-AL-H022

Description: The model failed to generate any valid AL code at all. The 'Generated code not found' note and the compilation error at line 60 (syntax error expecting '}') suggest the model either produced empty/malformed output or failed to produce a complete codeunit. The task required creating a complex codeunit with 8 procedures using RecordRef/FieldRef patterns, error handling with TryFunction-like patterns, and dynamic record manipulation. The model was unable to produce syntactically valid AL code for this complex task.

Correct Pattern:
codeunit 70224 "CG Dynamic Record Handler"
{
    Access = Public;

    procedure GetTableName(TableId: Integer): Text
    var
        RecRef: RecordRef;
    begin
        if not TryOpenTable(RecRef, TableId) then
            exit('');
        exit(RecRef.Name);
    end;

    // ... (complete implementation of all 8 procedures using RecordRef, FieldRef, KeyRef)
}
Incorrect Pattern:
// Generated code not found

Error Codes: AL0104

6 yaml-parsing-string-manipulation text-parsing-and-json-handling 1 CG-AL-M021

Description: The model generated AL code with multiple syntax errors including semicolon issues (AL0111) at various lines, likely from incorrect use of string operations or variable declarations, misuse of 'Key' as a variable name (AL0519 - reserved word), and general structural syntax errors. The generated code was not captured but the compilation errors indicate the model struggled with: (1) proper AL syntax for text splitting/parsing operations, (2) using 'Key' as a variable name which is reserved in AL, (3) proper foreach/iteration syntax over JSON objects, and (4) general AL procedure structure. The task and tests are valid - this is a complex string parsing task that requires manual YAML parsing since AL has no built-in YAML library, and the model failed to produce syntactically correct AL code.

Correct Pattern:
For YAML parsing in AL: split text by line feed character (char 10), then split each line by ': ' to get key-value pairs, store in JsonObject. Use variable names like 'KeyName' or 'PropertyKey' instead of reserved word 'Key'. For iterating JsonObject keys, use 'foreach PropertyName in JsonObj.Keys do' with proper AL syntax. Ensure all statements end with semicolons and proper begin/end blocks.
Incorrect Pattern:
// Generated code not available but errors indicate issues at lines 39, 54, 93, 104, 132 (semicolon expected) and line 143 using 'Key' as identifier

Error Codes: AL0111

7 parse-failure unknown 1 CG-AL-E052

Description: Failed to parse LLM analysis response: Looking at the failure details: 1. The generated code compiled successfully and most tests passed 2. Only `TestDateToText_ValidDate` and `TestDateToText_FirstDayOfYear` failed 3. The test for `TestDa

Correct Pattern:
Incorrect Pattern:
8 multiline-string-literals text-literal-syntax 1 CG-AL-E050

Description: The model attempted to use actual multiline string literals (spanning multiple lines in source code) which is not valid AL syntax in most BC versions. The AL0360 errors ('Text literal was not properly terminated') indicate the model wrote string literals that span across lines without proper termination. In AL, multiline text must be constructed using string concatenation with CR/LF characters, or using the newer AL multiline string literal syntax (triple-quoted strings) if supported. The model likely wrote something like 'SELECT CustomerNo, Name, Balance\nFROM Customer...' as a raw multiline string in the source, which the compiler rejected. The task explicitly asked for multiline string literals, but the model didn't know the correct AL syntax for achieving this (e.g., using concatenation with carriage return/line feed characters, or the proper triple-single-quote syntax for multiline literals if the runtime version supports it).

Correct Pattern:
In AL, multiline text can be achieved via concatenation: exit('SELECT CustomerNo, Name, Balance' + CrLf + 'FROM Customer' + CrLf + 'WHERE Active = true' + CrLf + 'ORDER BY Name'); where CrLf is built from char values 13 and 10. Alternatively, if the runtime supports it (runtime 12.0+), use triple-quoted multiline string literals with the syntax: '''...multiline content...'''
Incorrect Pattern:
exit('SELECT CustomerNo, Name, Balance
FROM Customer
WHERE Active = true
ORDER BY Name');

Error Codes: AL0360

9 complex-report-with-helper-codeunit report-definition-and-codeunit-generation 1 CG-AL-M007

Description: The model failed to generate any valid AL code at all. The task required creating both a Report 70001 'Sales Performance Analysis' and a helper codeunit 'CG-AL-M007 Mock Calculator' that the test file references. The generated code appears to be empty or syntactically broken (compilation error at line 31 with 'Syntax error, } expected' and 'App generation failed'). The model did not understand how to produce a complete solution consisting of: (1) a report object with multiple data items (Customer, Sales Header, Sales Line), request page, and triggers, and (2) a mock calculator codeunit with procedures like Initialize(), AddSalesLine(), GetRunningTotalByCustomer(), GetRunningTotalByRegion(), CalculateAverageOrderValue(), GetCustomerRank(), GetTopProduct(), GetProductSalesQuantity(), CalculateYoYComparison(), CalculateOrderFrequency(), GetTotalSales(), and GetCustomerCount(). The model either produced no output or produced fundamentally broken AL syntax.

Correct Pattern:
The solution requires at minimum two AL objects:

1. report 70001 "Sales Performance Analysis" with DataItems for Customer, Sales Header, Sales Line, request page with date filters, and proper ApplicationArea/UsageCategory.

2. codeunit XXXXX "CG-AL-M007 Mock Calculator" with procedures:
   - Initialize()
   - AddSalesLine(CustomerCode: Code[20]; Region: Code[20]; ItemCode: Code[20]; Quantity: Decimal; Amount: Decimal)
   - GetRunningTotalByCustomer(CustomerCode: Code[20]): Decimal
   - GetRunningTotalByRegion(Region: Code[20]): Decimal
   - CalculateAverageOrderValue(): Decimal
   - GetCustomerRank(CustomerCode: Code[20]): Integer
   - GetTopProduct(): Code[20]
   - GetProductSalesQuantity(ItemCode: Code[20]): Decimal
   - CalculateYoYComparison(CurrentYear: Decimal; PreviousYear: Decimal): Decimal
   - CalculateOrderFrequency(OrderCount: Integer; Days: Integer): Decimal
   - GetTotalSales(): Decimal
   - GetCustomerCount(): Integer

Using temporary record variables or Dictionary collections to store and aggregate the in-memory sales data.
Incorrect Pattern:
// Generated code not found (empty or completely invalid output causing syntax error at line 31)

Error Codes: AL0104

10 multiline-string-literals string-operations 1 CG-AL-E050

Description: The model failed to properly use AL multiline string literals. The task requires using multiline string literals (a relatively newer AL feature), but the model appears to have attempted to use single-quoted strings with embedded newlines or incorrect syntax, resulting in AL0360 'Text literal was not properly terminated' errors. In AL, multiline text literals are not supported via traditional single-quoted strings spanning multiple lines. The model likely tried to break a string across lines without proper termination. The correct approach would be to either use string concatenation with CR/LF characters, or use the newer AL multiline string literal syntax (triple-quoted strings or similar), or use StrSubstNo/TextConst patterns. The compilation errors at lines 22-30 indicate the model wrote string literals that span multiple lines without proper AL syntax.

Correct Pattern:
In AL, multiline text literals should use the triple-single-quote syntax introduced in newer AL versions:

procedure GetSqlQuery(): Text
begin
    exit('''SELECT CustomerNo, Name, Balance
FROM Customer
WHERE Active = true
ORDER BY Name''');
end;

Alternatively, if the runtime doesn't support triple-quoted strings, use concatenation with newline characters:
var CrLf: Text[2];
begin
    CrLf[1] := 13;
    CrLf[2] := 10;
    exit('SELECT CustomerNo, Name, Balance' + CrLf + 'FROM Customer' + CrLf + 'WHERE Active = true' + CrLf + 'ORDER BY Name');
end;
Incorrect Pattern:
Unable to retrieve exact generated code, but based on errors at line 22-24, the model likely wrote something like:
exit('SELECT CustomerNo, Name, Balance
FROM Customer
WHERE Active = true
ORDER BY Name');

Error Codes: AL0360

11 al-if-then-case-syntax control-flow-syntax 1 CG-AL-H001

Description: The model generated AL code with multiple syntax errors around control flow statements (if/then/else, case). The compilation errors indicate missing 'then' keywords after 'if' conditions, orphaned 'else' statements due to incorrect semicolon placement before 'else', and mismatched 'end' statements. These are fundamental AL syntax issues where the model likely confused AL syntax with another language (e.g., using curly braces or missing 'then' keyword, placing semicolons before 'else' in if-then-else chains). The generated code was not captured but the errors clearly point to the model failing to produce syntactically valid AL control flow structures.

Correct Pattern:
In AL, if-then-else must follow: if <condition> then <statement> else <statement>; — no semicolon before 'else'. Case statements: case <variable> of <value>: <statement>; end; Proper begin/end pairing for compound statements.
Incorrect Pattern:
Generated code not available, but errors at line 24 show missing 'then', line 26 shows orphaned ELSE due to semicolon before else, and lines 48-53 show mismatched begin/end blocks

Error Codes: AL0104

12 procedure-declaration-syntax codeunit-procedure-definition 1 CG-AL-H009

Description: The model generated AL code with syntax errors around procedure declarations. The compilation errors (identifier expected where 'begin' keyword found, mismatched parentheses, missing semicolons) indicate the model produced malformed procedure signatures - likely missing return type declarations, incorrect parameter syntax, or improperly structured procedure bodies. The task and test are valid; the model simply failed to produce syntactically correct AL code for a codeunit with multiple procedures that have return values and proper variable declarations.

Correct Pattern:
procedure CalculateLineAmount(UnitPrice: Decimal; Quantity: Decimal; DiscountPercent: Decimal; CurrencyCode: Code[10]): Decimal
var
    Currency: Record Currency;
    LineAmount: Decimal;
    Precision: Decimal;
begin
    LineAmount := UnitPrice * Quantity;
    LineAmount := LineAmount * (1 - DiscountPercent / 100);
    if CurrencyCode <> '' then begin
        if Currency.Get(CurrencyCode) then
            Precision := Currency."Amount Rounding Precision"
        else begin
            Currency.InitRoundingPrecision();
            Precision := Currency."Amount Rounding Precision";
        end;
    end else
        Precision := 0.01;
    exit(Round(LineAmount, Precision, '='));
end;
Incorrect Pattern:
Generated code not available but errors at line 23 suggest malformed procedure declaration around the begin keyword, likely a procedure missing its return type or having incorrect parameter syntax

Error Codes: AL0105

13 enum-and-codeunit-combined-file-syntax enum-definition 1 CG-AL-H007

Description: The model generated code that placed the enum definition incorrectly, likely putting the enum 'value' keywords in a context where the AL compiler expected codeunit syntax. The compilation error at line 67 shows 'value' keyword being unexpected, which indicates the model either combined the enum and codeunit in a single file incorrectly, or used wrong syntax for the enum definition. The 'value' keyword is specific to enum objects and must appear inside a properly declared enum block. The model failed to produce valid AL code - the generated code was not even captured ('Generated code not found'), suggesting a fundamental failure in code generation for this task involving ErrorInfo, CustomDimensions, and enum definitions.

Correct Pattern:
enum 70211 "CG Validation Error"
{
    Extensible = false;
    value(0; None) { }
    value(1; EmptyField) { }
    value(2; InvalidFormat) { }
    value(3; OutOfRange) { }
    value(4; DuplicateValue) { }
}

codeunit 70210 "CG Validation Engine"
{
    Access = Public;

    procedure CreateValidationError(ErrorCode: Enum "CG Validation Error"; FieldName: Text; ErrorMessage: Text): ErrorInfo
    var
        ErrInfo: ErrorInfo;
        Dims: Dictionary of [Text, Text];
    begin
        ErrInfo.Message(ErrorMessage);
        Dims.Add('ErrorCode', Format(ErrorCode.AsInteger()));
        Dims.Add('FieldName', FieldName);
        ErrInfo.CustomDimensions(Dims);
        ErrInfo.Collectible(IsCollectingErrors());
        exit(ErrInfo);
    end;

    procedure GetErrorCode(ErrInfo: ErrorInfo): Enum "CG Validation Error"
    var
        ErrorCodeText: Text;
        ErrorCodeInt: Integer;
    begin
        ErrorCodeText := ErrInfo.CustomDimensions.Get('ErrorCode');
        Evaluate(ErrorCodeInt, ErrorCodeText);
        exit(Enum::"CG Validation Error".FromInteger(ErrorCodeInt));
    end;

    procedure ValidateNotEmpty(Value: Text; FieldName: Text)
    var
        ErrInfo: ErrorInfo;
    begin
        if Value = '' then begin
            ErrInfo := CreateValidationError("CG Validation Error"::EmptyField, FieldName, 'Field cannot be empty');
            Error(ErrInfo);
        end;
    end;

    procedure ValidateInRange(Value: Decimal; MinValue: Decimal; MaxValue: Decimal; FieldName: Text)
    var
        ErrInfo: ErrorInfo;
    begin
        if (Value < MinValue) or (Value > MaxValue) then begin
            ErrInfo := CreateValidationError("CG Validation Error"::OutOfRange, FieldName, StrSubstNo('Value must be between %1 and %2', MinValue, MaxValue));
            Error(ErrInfo);
        end;
    end;
}
Incorrect Pattern:
value(0; None) -- appearing at line 67 outside proper enum context

Error Codes: AL0104

14 json-api-methods-syntax json-handling 1 CG-AL-H014

Description: The model failed to generate valid AL code for the CG JSON Parser codeunit. The generated code has multiple syntax errors (missing 'end' keywords, semicolons, etc.) around lines 23-65, indicating the model does not properly understand how to structure AL codeunit procedures that work with JsonObject, JsonArray, and JsonToken types. The task and test are valid - the model simply produced syntactically broken AL code. The 'Generated code not found' note and the compilation errors at specific line numbers confirm the model produced something but with fundamental structural/syntax issues in the AL procedure bodies, likely misusing JSON API methods like Get(), AsObject(), AsDecimal() or incorrectly structuring control flow (for loops, if statements) when iterating JSON arrays and navigating nested objects.

Correct Pattern:
codeunit 70014 "CG JSON Parser"
{
    procedure ParseCustomerData(CustomerJson: JsonObject): Text
    var
        NameToken: JsonToken;
        AgeToken: JsonToken;
        ActiveToken: JsonToken;
        CustomerName: Text;
        Age: Integer;
        Active: Boolean;
    begin
        CustomerJson.Get('name', NameToken);
        CustomerName := NameToken.AsValue().AsText();
        CustomerJson.Get('age', AgeToken);
        Age := AgeToken.AsValue().AsInteger();
        CustomerJson.Get('active', ActiveToken);
        Active := ActiveToken.AsValue().AsBoolean();
        exit(StrSubstNo('Name: %1, Age: %2, Active: %3', CustomerName, Age, Active));
    end;

    procedure ProcessOrderItems(OrderJson: JsonObject): Integer
    var
        ItemsToken: JsonToken;
        ItemsArray: JsonArray;
        ItemToken: JsonToken;
        ItemObj: JsonObject;
        QtyToken: JsonToken;
        Total: Integer;
        i: Integer;
    begin
        OrderJson.Get('items', ItemsToken);
        ItemsArray := ItemsToken.AsArray();
        for i := 0 to ItemsArray.Count() - 1 do begin
            ItemsArray.Get(i, ItemToken);
            ItemObj := ItemToken.AsObject();
            ItemObj.Get('quantity', QtyToken);
            Total += QtyToken.AsValue().AsInteger();
        end;
        exit(Total);
    end;

    procedure SafeGetText(Obj: JsonObject; Key: Text; DefaultValue: Text): Text
    var
        Token: JsonToken;
    begin
        if Obj.Get(Key, Token) then
            exit(Token.AsValue().AsText());
        exit(DefaultValue);
    end;

    procedure ExtractNestedValue(RootJson: JsonObject): Decimal
    var
        Token: JsonToken;
        DataObj: JsonObject;
        DetailsObj: JsonObject;
    begin
        RootJson.Get('data', Token);
        DataObj := Token.AsObject();
        DataObj.Get('details', Token);
        DetailsObj := Token.AsObject();
        DetailsObj.Get('amount', Token);
        exit(Token.AsValue().AsDecimal());
    end;
}
Incorrect Pattern:
// Generated code not found - but compilation errors indicate structurally broken code with missing 'end' statements and semicolons around JSON parsing logic

Error Codes: AL0104

15 query-crossjoin-syntax query-definition 1 CG-AL-H017

Description: The model failed to generate valid AL code for the query object. The generated output appears to contain prose/explanation text instead of proper AL code (the errors at line 28 reference words like 'correctly' and backtick characters, indicating the model output natural language or markdown instead of pure AL code). The model did not produce a syntactically valid AL query object with CrossJoin dataitems, proper column definitions, and LeftOuterJoin for the Dimension Set Entry dataitem.

Correct Pattern:
query 70017 "CG Dimension Matrix"
{
    QueryType = Normal;

    elements
    {
        dataitem(DepartmentDimValue; "Dimension Value")
        {
            SqlJoinType = CrossJoin;
            filter(Dimension_Code; "Dimension Code") { ColumnFilter = const('DEPARTMENT'); }
            column(DepartmentCode; "Code") { }
            column(DepartmentName; Name) { }

            dataitem(ProjectDimValue; "Dimension Value")
            {
                SqlJoinType = CrossJoin;
                filter(Project_Dimension_Code; "Dimension Code") { ColumnFilter = const('PROJECT'); }
                column(ProjectCode; "Code") { }
                column(ProjectName; Name) { }

                dataitem(DimSetEntry; "Dimension Set Entry")
                {
                    SqlJoinType = LeftOuterJoin;
                    DataItemLink = "Dimension Code" = DepartmentDimValue."Dimension Code";
                    column(MatchCount; "Dimension Value ID") { Method = Count; }
                }
            }
        }
    }
}
Incorrect Pattern:
// Generated code not found - but compilation errors suggest the model output contained prose text with backticks and words like 'correctly' instead of valid AL code

Error Codes: AL0104

16 collection-type-syntax-and-procedure-structure list-dictionary-types 1 CG-AL-H020

Description: The model failed to generate valid AL code for a codeunit using List and Dictionary collection types. The compilation errors (semicolon expected, 'end' expected at multiple lines around line 50+) indicate the model produced syntactically invalid AL code, likely struggling with the complex generic type syntax (e.g., 'Dictionary of [Text, List of [Text]]' for GroupByFirstLetter) and proper procedure structure when working with AL collection types. The generated code was not captured but the errors point to malformed procedure bodies, possibly incorrect handling of nested generic types or improper begin/end blocks.

Correct Pattern:
codeunit 70020 "CG Collection Processor"
{
    procedure JoinTexts(Items: List of [Text]; Separator: Text): Text
    var
        Result: Text;
        Item: Text;
        IsFirst: Boolean;
    begin
        IsFirst := true;
        foreach Item in Items do begin
            if IsFirst then
                IsFirst := false
            else
                Result += Separator;
            Result += Item;
        end;
        exit(Result);
    end;

    procedure FilterByPrefix(Items: List of [Text]; Prefix: Text): List of [Text]
    var
        Result: List of [Text];
        Item: Text;
    begin
        foreach Item in Items do
            if Item.StartsWith(Prefix) then
                Result.Add(Item);
        exit(Result);
    end;

    procedure SumDecimals(Numbers: List of [Decimal]): Decimal
    var
        Result: Decimal;
        Num: Decimal;
    begin
        foreach Num in Numbers do
            Result += Num;
        exit(Result);
    end;

    procedure MapToUpperCase(var Items: List of [Text])
    var
        i: Integer;
        Item: Text;
    begin
        for i := 1 to Items.Count() do begin
            Items.Get(i, Item);
            Items.Set(i, UpperCase(Item));
        end;
    end;

    procedure MergeDictionaries(Dict1: Dictionary of [Text, Text]; Dict2: Dictionary of [Text, Text]): Dictionary of [Text, Text]
    var
        Result: Dictionary of [Text, Text];
        Key: Text;
        Value: Text;
    begin
        foreach Key in Dict1.Keys() do begin
            Dict1.Get(Key, Value);
            Result.Set(Key, Value);
        end;
        foreach Key in Dict2.Keys() do begin
            Dict2.Get(Key, Value);
            Result.Set(Key, Value);
        end;
        exit(Result);
    end;

    procedure GroupByFirstLetter(Items: List of [Text]): Dictionary of [Text, List of [Text]]
    var
        Result: Dictionary of [Text, List of [Text]];
        Item: Text;
        FirstLetter: Text;
        Group: List of [Text];
    begin
        foreach Item in Items do begin
            FirstLetter := CopyStr(Item, 1, 1);
            if Result.ContainsKey(FirstLetter) then
                Result.Get(FirstLetter, Group)
            else
                Clear(Group);
            Group.Add(Item);
            Result.Set(FirstLetter, Group);
        end;
        exit(Result);
    end;

    procedure GetKeys(Dict: Dictionary of [Code[20], Decimal]): List of [Code[20]]
    var
        Result: List of [Code[20]];
        Key: Code[20];
    begin
        foreach Key in Dict.Keys() do
            Result.Add(Key);
        exit(Result);
    end;
}
Incorrect Pattern:
// Generated code not found - but errors at lines 50-74 indicate syntax issues in procedure bodies, likely around GroupByFirstLetter or MergeDictionaries procedures

Error Codes: AL0111

17 al-control-flow-syntax basic-al-syntax 1 CG-AL-H022

Description: The model generated code with fundamental AL syntax errors including missing 'then' keywords after 'if' conditions, misplaced 'end' statements, missing semicolons, and unbalanced parentheses. The generated code was not found/empty in the report, but the compilation errors at specific lines (25, 26, 47-52, 72) indicate the model produced syntactically invalid AL code with multiple structural issues. These are basic AL syntax mistakes - the model failed to properly write if-then-begin-end blocks, procedure structures, and expression syntax for a codeunit involving RecordRef/FieldRef operations.

Correct Pattern:
Proper AL syntax requires: 'if <condition> then begin ... end;' blocks, semicolons after statements, balanced parentheses in expressions, and proper procedure/begin/end structure. For example: 'if RecRef.FieldExist(FieldNo) then begin FldRef := RecRef.Field(FieldNo); exit(Format(FldRef.Value)); end;'
Incorrect Pattern:
// Generated code not available but compilation errors indicate: missing 'then' at line 25, missing 'end' at lines 47-49/52, missing semicolons at lines 26/50, missing ')' at line 72

Error Codes: AL0104

18 string-literal-termination-and-page-structure page-definition 1 CG-AL-M004

Description: The model generated AL code with multiple fundamental errors: (1) A text literal was not properly terminated (AL0360 at line 128), likely a string with an unescaped or missing closing single quote. (2) The page structure was broken, causing properties like SourceTable, SourceTableView, and UsageCategory to appear outside a valid page context (AL0124 errors at lines 135-139). This suggests the model likely closed the page object prematurely (perhaps due to the unterminated string literal causing cascading parse errors) and then had page properties appearing as if they belonged to a second object definition. The errors cascade from the initial string literal issue at line 128, which broke the parser's understanding of the page structure, leading to all subsequent errors including misplaced properties and syntax errors.

Correct Pattern:
page 70101 "Sales Order Workspace"
{
    PageType = Card;
    SourceTable = "Sales Header";
    SourceTableView = where("Document Type" = const(Order));
    UsageCategory = None;
    Caption = 'Sales Order Workspace';

    layout
    {
        area(Content)
        {
            group(General)
            {
                field("No."; Rec."No.") { ApplicationArea = All; }
                field("Sell-to Customer No."; Rec."Sell-to Customer No.") { ApplicationArea = All; }
                // ... other fields
            }
            group(Financial)
            {
                field(Amount; Rec.Amount) { ApplicationArea = All; }
                field("Amount Including VAT"; Rec."Amount Including VAT") { ApplicationArea = All; }
            }
            part(Lines; "Sales Order Subform") { ApplicationArea = All; SubPageLink = "Document No." = field("No."); }
        }
    }
    actions
    {
        area(Processing)
        {
            action(CalculateTotals)
            {
                ApplicationArea = All;
                Caption = 'Calculate Totals';
                Promoted = true;
                Enabled = IsNotReleased;
                trigger OnAction()
                begin
                    Rec.CalcFields(Amount, "Amount Including VAT");
                    Message('Totals calculated: Amount = %1, Amount Incl. VAT = %2', Rec.Amount, Rec."Amount Including VAT");
                end;
            }
            // ... other actions with proper string termination
        }
    }
    var
        IsNotReleased: Boolean;
    trigger OnAfterGetRecord()
    begin
        IsNotReleased := Rec.Status <> Rec.Status::Released;
    end;
}
Incorrect Pattern:
Line 128 contains an unterminated text literal, and lines 135-139 have SourceTable/SourceTableView/UsageCategory properties outside a valid page context

Error Codes: AL0360

19 table-extension-structure table-extension-definition 1 CG-AL-M006

Description: The model generated code with fundamental AL syntax errors starting at line 21. The compilation errors (expecting ';', identifier, keywords like 'begin' misplaced, expecting application object keywords like 'tableextension') indicate the model failed to produce a properly structured AL table extension. The errors suggest the model likely mixed up procedural code with the table extension declaration structure, possibly placing procedure bodies (with 'begin' keyword) outside of proper context, or failed to properly structure the tableextension object with its fields section and procedure declarations. The generated code file appears to have severe structural issues where AL object-level syntax is broken.

Correct Pattern:
tableextension 70001 "Advanced Customer Extension" extends Customer
{
    fields
    {
        field(50000; "Credit Score"; Integer)
        {
            DataClassification = CustomerContent;
            trigger OnValidate()
            begin
                if ("Credit Score" < 300) or ("Credit Score" > 850) then
                    Error('Credit Score must be between 300 and 850');
            end;
        }
        field(50001; "Risk Level"; Option)
        {
            OptionMembers = Low,Medium,High,Critical;
            DataClassification = CustomerContent;
        }
        field(50002; "Last Risk Assessment Date"; Date)
        {
            DataClassification = CustomerContent;
        }
        field(50003; "Payment History Rating"; Decimal)
        {
            DataClassification = CustomerContent;
        }
        field(50004; "Preferred Payment Method"; Code[10])
        {
            TableRelation = "Payment Method";
            DataClassification = CustomerContent;
        }
    }

    procedure UpdateRiskLevel()
    begin
        if "Credit Score" >= 670 then
            "Risk Level" := "Risk Level"::Low
        else if "Credit Score" >= 580 then
            "Risk Level" := "Risk Level"::Medium
        else if "Credit Score" >= 500 then
            "Risk Level" := "Risk Level"::High
        else
            "Risk Level" := "Risk Level"::Critical;
    end;

    procedure CalculatePaymentHistoryRating(): Decimal
    begin
        exit(50.0);
    end;

    procedure GetCreditLimit(): Decimal
    begin
        case "Risk Level" of
            "Risk Level"::Low: exit(100000);
            "Risk Level"::Medium: exit(50000);
            "Risk Level"::High: exit(10000);
            "Risk Level"::Critical: exit(1000);
        end;
    end;

    procedure ValidateNewOrder(OrderAmount: Decimal): Boolean
    begin
        exit(OrderAmount <= GetCreditLimit());
    end;

    procedure TriggerRiskAssessment()
    begin
        UpdateRiskLevel();
        "Last Risk Assessment Date" := Today;
        Modify();
    end;
}
Incorrect Pattern:
// Generated code not found - but compilation errors at line 21 indicate structural syntax failure with 'begin' keyword appearing where an application object declaration was expected

Error Codes: AL0104

20 json-object-value-extraction json-handling-codeunit 1 CG-AL-M020

Description: The model failed to generate valid AL code for the codeunit. The generated code has fundamental syntax errors starting at line 21, suggesting the model produced malformed AL code - possibly including markdown fences, incorrect structure, or invalid syntax for JSON handling procedures. The task and test are valid; the model simply failed to produce a compilable AL codeunit that properly handles JsonObject, JsonToken, JsonValue, JsonArray types and Dictionary return types.

Correct Pattern:
codeunit 70120 "CG JSON Value Extractor"
{
    Access = Public;

    procedure ExtractProductInfo(ProductJson: JsonObject): Text
    var
        JToken: JsonToken;
        JValue: JsonValue;
        ProductName: Text;
        Price: Decimal;
        InStock: Boolean;
        Quantity: Integer;
    begin
        ProductJson.Get('name', JToken);
        ProductName := JToken.AsValue().AsText();
        ProductJson.Get('price', JToken);
        Price := JToken.AsValue().AsDecimal();
        ProductJson.Get('inStock', JToken);
        InStock := JToken.AsValue().AsBoolean();
        ProductJson.Get('quantity', JToken);
        Quantity := JToken.AsValue().AsInteger();
        exit(StrSubstNo('Product: %1, Price: %2, In Stock: %3, Qty: %4', ProductName, Format(Price), Format(InStock), Format(Quantity)));
    end;

    procedure ExtractWithDefaults(DataJson: JsonObject; Key: Text): Text
    var
        JToken: JsonToken;
    begin
        if DataJson.Get(Key, JToken) then
            exit(JToken.AsValue().AsText());
        exit('N/A');
    end;

    procedure SumArrayValues(DataJson: JsonObject): Integer
    var
        JToken: JsonToken;
        JArray: JsonArray;
        i: Integer;
        Sum: Integer;
    begin
        DataJson.Get('values', JToken);
        JArray := JToken.AsArray();
        for i := 0 to JArray.Count - 1 do begin
            JArray.Get(i, JToken);
            Sum += JToken.AsValue().AsInteger();
        end;
        exit(Sum);
    end;

    procedure ParseConfigSettings(ConfigJson: JsonObject): Dictionary of [Text, Text]
    var
        Result: Dictionary of [Text, Text];
        Keys: List of [Text];
        Key: Text;
        JToken: JsonToken;
    begin
        Keys := ConfigJson.Keys;
        foreach Key in Keys do begin
            ConfigJson.Get(Key, JToken);
            Result.Add(Key, Format(JToken.AsValue()));
        end;
        exit(Result);
    end;

    procedure HandleMissingKeys(PartialJson: JsonObject): Text
    var
        JToken: JsonToken;
    begin
        if PartialJson.Get('required', JToken) then
            exit(JToken.AsValue().AsText());
        if PartialJson.Get('optional', JToken) then
            exit(JToken.AsValue().AsText());
        exit('none');
    end;
}
Incorrect Pattern:
// Generated code not found - but compilation errors at line 21 indicate syntax breakdown, likely malformed procedure body or markdown artifacts in output

Error Codes: AL0107

21 yaml-parsing-al-syntax codeunit-procedure-structure 1 CG-AL-M021

Description: The model failed to generate valid AL code for the YAML Handler codeunit. The compilation errors (semicolon expected, 'end' expected at multiple lines) indicate the model produced code with fundamental AL syntax errors - likely mixing non-AL constructs or having malformed procedure bodies. The task and tests are valid; the model simply couldn't produce syntactically correct AL code for parsing YAML-like text content using string manipulation and JsonObject. Since AL has no native YAML library, the model needed to implement manual string splitting/parsing logic and apparently failed to structure the codeunit properly.

Correct Pattern:
codeunit 70121 "CG YAML Handler"
{
    Access = Public;

    procedure ParseYamlConfig(YamlContent: Text): Text
    var
        JsonObj: JsonObject;
        Lines: List of [Text];
        Line: Text;
        Key: Text;
        Value: Text;
        ColonPos: Integer;
        NameVal: Text;
        VersionVal: Text;
        DebugVal: Text;
        PortVal: Text;
        JToken: JsonToken;
        Lf: Text[1];
    begin
        Lf[1] := 10;
        Lines := YamlContent.Split(Lf);
        foreach Line in Lines do begin
            ColonPos := Line.IndexOf(':');
            if ColonPos > 0 then begin
                Key := Line.Substring(1, ColonPos - 1).Trim();
                Value := Line.Substring(ColonPos + 1).Trim();
                JsonObj.Add(Key, Value);
            end;
        end;
        JsonObj.Get('name', JToken); NameVal := JToken.AsValue().AsText();
        JsonObj.Get('version', JToken); VersionVal := JToken.AsValue().AsText();
        JsonObj.Get('debug', JToken); DebugVal := JToken.AsValue().AsText();
        JsonObj.Get('port', JToken); PortVal := JToken.AsValue().AsText();
        exit(StrSubstNo('App: %1 v%2, Debug: %3, Port: %4', NameVal, VersionVal, DebugVal, PortVal));
    end;
    // ... other procedures similarly structured
}
Incorrect Pattern:
// Generated code not found - but compilation errors at lines 23-64 suggest malformed procedure bodies with missing semicolons and end statements

Error Codes: AL0111

22 setloadfields-multiline-syntax partial-record-loading 1 CG-AL-M023

Description: The model generated code with a syntax error around SetLoadFields calls, likely splitting the field list across multiple lines incorrectly or using a trailing comma. The AL0301 error 'A list must end with a member; not a separator ,' at line 23:38 indicates the model placed a comma at the end of a parameter list (likely in a SetLoadFields call) without a following argument, possibly breaking the call across lines incorrectly. The cascading syntax errors (expecting ')', semicolons, 'end') all stem from this initial malformed function call. The generated code was not captured but the compilation errors clearly show the model failed to produce syntactically valid AL code for what should be a straightforward codeunit with SetLoadFields usage.

Correct Pattern:
Customer.SetLoadFields(Name);
if Customer.FindSet() then
    repeat
        Names.Add(Customer.Name);
    until Customer.Next() = 0;
Incorrect Pattern:
Customer.SetLoadFields(Name,
  ...)

Error Codes: AL0301

23 query-object-definition query-object-syntax 1 CG-AL-H011

Description: The model failed to generate any valid AL code for the query object. The generated code was either empty or completely malformed, resulting in syntax errors at line 23 indicating the compiler expected an application object keyword (like 'query') but found something else entirely. The model does not know how to properly define an AL query object with dataitems, columns, aggregation methods, column filters, and ordering.

Correct Pattern:
query 70011 "CG Sales Summary"
{
    QueryType = Normal;
    OrderBy = ascending(Sell_to_Customer_No);

    elements
    {
        dataitem(SalesLine; "Sales Line")
        {
            column(Document_No; "Document No.") { }
            column(Sell_to_Customer_No; "Sell-to Customer No.") { }
            column(Line_Amount_Sum; "Line Amount") { Method = Sum; }
            column(Line_Count; "Line Amount") { Method = Count; }
            filter(Document_Type; "Document Type") { ColumnFilter = const(Order); }
        }
    }
}
Incorrect Pattern:
// Generated code not found (empty or malformed output)

Error Codes: AL0104