microsoft / microsoft/AL

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

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

Nobody has claimed this yet.

accepted al-core-compiler
Dominant language
PowerShell
Stars
881
Forks
285
Avg merge
3d 36m
Merged PRs (30d)
1

Description

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:
    • Windows
    • Linux
    • MacOS
      Internal work item: AB#582319

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 Apps.zip: deploy all apps in the FullStack workspace, then compile and publish app C from the SomeStack workspace and compare it with compiling C alone. Use the reported AL0133 diagnostic and log output as the failure criteria. Done means SomeStack compiles app C without the conversion error or corresponding log error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.