microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
748 stars 244 forks source link

error AL0570: Same label var name in same codeunit results in same translation ID #7844

Closed cristof-thomas closed 2 months ago

cristof-thomas commented 2 months ago

Please include the following with each issue:

1. Describe the bug error AL0570: Same label var name in same codeunit results in same translation ID

2. To Reproduce codeunit 1234 my_codeunit { procedure p1() var lbl1: Label 'label1'; begin end;

procedure p2() var lbl1: Label 'label2'; begin end; }

...\my_codeunit.al(y1,x1): error AL0570: The symbol 'lbl1' results in the same translation ID as one or more other symbols. Rename symbol to resolve the problem. ...\my_codeunit.al(y2,x2): error AL0570: The symbol 'lbl1' results in the same translation ID as one or more other symbols. Rename symbol to resolve the problem.

  1. Go to '...'
AL code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally.

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 2 differents translation ID generated

4. Actual behavior error with same translation ID

5. Versions:

Please remember to do the following:

thpeder commented 2 months ago

Hi @cristof-thomas,

I just tried out the code that you have in the issue description, and it does not reproduce for me. This is the generated translation file.

<trans-unit id="Codeunit 2605812460 - Method 2186843627 - NamedType 1006928925" size-unit="char" translate="yes" xml:space="preserve">
  <source>label1</source>
  <note from="Developer" annotates="general" priority="2"></note>
  <note from="Xliff Generator" annotates="general" priority="3">Codeunit my_codeunit - Method p1 - NamedType lbl1</note>
</trans-unit>
<trans-unit id="Codeunit 2605812460 - Method 4099933478 - NamedType 1006928925" size-unit="char" translate="yes" xml:space="preserve">
  <source>label2</source>
  <note from="Developer" annotates="general" priority="2"></note>
  <note from="Xliff Generator" annotates="general" priority="3">Codeunit my_codeunit - Method p2 - NamedType lbl1</note>
</trans-unit>

That being said, the Ids of a trans-unit is a hash of the names involved, which means that there can occur collisions. We have therefor included multiple elements to help avoid that situation. For instance in the example above. Codeunit my_codeunit - Method p2 - NamedType lbl1

If you encounter such diagnostic the best recommendation I have for you is to rename the local variable inside the procedure