AL icon indicating copy to clipboard operation
AL copied to clipboard

Invalid compile error when using a mix of symbols and code in a workspace.

Open NicolaiEsbensen opened this issue 8 months ago • 0 comments

1. Describe the bug I've attached a zip file containing 3 apps and two workspaces. The Fullstack workspace refers 3 apps. Top level app A, with no references.

codeunit 50101 "Codeunit A"
{
}

2nd level app B, providing a procedure which takes an instance of a Codeunit in A as an argument by reference.

codeunit 50102 "Codeunit B"
{
    procedure MethodInBWithAByReference(var A: Codeunit "Codeunit A")
    begin
    end;
}

3rd level app C, which defines a procedure that invokes the procedure provided in app B, and providing an instance of the codeunit defined in A.

codeunit 50103 "Codeunit C"
{
    var
        CodeunitA: Codeunit "Codeunit A";

    procedure BreakingError()
    var
        CodeunitB: Codeunit "Codeunit B";
    begin
        CodeunitB.MethodInBWithAByReference(CodeunitA);
    end;

}

The fullstack workspace compiles just fine and gives no error. The Somestack workspace however, gives a compile error and an error in the log. The Somestack workspace only includes A and C in the workspace.

C.Codeunit.al(10,45): error AL0133: Argument 1: cannot convert from 'Codeunit "Codeunit A"' to 'var Codeunit "Codeunit A"'

2. To Reproduce

I've created a sample workspace to reproduce the issue:

Apps.zip

First, open FullStack workspace and deploy all apps. Then open the SomeStack workspace, and try to compile and publish app C. The error described will occur. Note: Compile app C on it's own will succeed.

Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.

3. Expected behavior Expect app C to compile without any issues or errors.

4. Actual behavior App C fails to compile

Show the problem:

Image

The log produces this output:

Image

5. Versions:

  • AL Language: Both 16.0.1493797 and 15.0.1433841. (Appears to also be an issue in 13.x and 14.x)
  • Visual Studio Code: 1.100.0
  • Business Central: 26.0.30643.32481 (Again seems to be an issue in lower versions as well)
  • List of Visual Studio Code extensions that you have installed:
  • Operating System:
    • [X] Windows
    • [ ] Linux
    • [ ] MacOS Internal work item: AB#582319

NicolaiEsbensen avatar May 13 '25 06:05 NicolaiEsbensen