microsoft / microsoft/AL

List.AddRange | Throws unhandled CLR exception for empty list of interfaces

Open
#8,241 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accepted bug platform-api
Dominant language
PowerShell
Stars
881
Forks
285
Avg merge
3d 36m
Merged PRs (30d)
1

Description

1. Describe the bug

For List variables that are either a list of interfaces or even a list of codeunits that contain an interface as a global variable, AddRange is unstable. Specifically it throws an unhandled CLR exception when the list in the parameter is empty.

2. To Reproduce

  1. Define a list of interfaces
  2. Define another list of interfaces
  3. Call AddRange, passing the empty list of interfaces
    [Test]
    procedure AddRange_Passes_WhenListIsEmpty()
    var
        BaseList: List of [Interface "AOAI Function"];
        EmptyList: List of [Interface "AOAI Function"];
    begin
        // Fails with CLR exception
        BaseList.AddRange(EmptyList);
    end;

3. Expected behavior

AddRange successfully does nothing when the provided list is empty, regardless of type.

4. Actual behavior

CLR exception when the provided list of interfaces is empty.

5. Versions:

Occurs using artifacts from this URL: https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/27.5.46862.47203/us

Also occurs using the latest AL runtime with AL Language version = 18.0.2293710

Internal work item: AB#634112

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the AddRange_Passes_WhenListIsEmpty test scenario from the issue, using two empty and base List variables of Interface "AOAI Function". Reproduce it against the stated AL runtime versions and verify that AddRange completes without a CLR exception and leaves the base list unchanged.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.