Skip to content

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

@zeande

Description

@zeande

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedbugProduct bugplatform-apiIssue related to the API exposed by the platform through the AL library.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions