Bug in using "continue" in nested foreach loop
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start by running the provided AL codeunit reproduction with AL Language 18.0.2732683 and Business Central 28.4, then trace how nested foreach and continue are handled by the compiler or language extension. Done means continue skips only the current foreach iteration, producing messages for items B and C in the expected outer-loop iterations.
Written by the indexing model from the issue text.
Description
Please include the following with each issue:
1. Describe the bug
When using continue inside a foreach loop that resides within another loop, continue will step out of the inner foreach loop.
2. To Reproduce
Steps to reproduce the behavior:
- Go to '...'
codeunit 50000 "MyContinueTest"
{
trigger OnRun()
var
List: List of [Code[1]];
Item: Code[1];
FieldNo: Integer;
Nos: Integer;
begin
Nos := 5;
List.Add('A');
List.Add('B');
List.Add('C');
for FieldNo := 1 to Nos do begin
if FieldNo = 3 then
continue;
foreach Item in List do
if item = 'A' then
continue
else
Message('Field No: %1 Processing item: %2', FieldNo,Item);
end;
end;
}
3. Expected behavior
In the example above I would expect message boxes with Fieldnos 1 to 3 and item B and C.
4. Actual behavior
I get no Message box at all!
5. Versions:
- AL Language: 18.0.2732683
- Visual Studio Code: 1.137.0
- Business Central: 28.4
- List of Visual Studio Code extensions that you have installed: Disabled
- Operating System:
- Windows
- Linux
- MacOS
Final Checklist
Please remember to do the following:
-
Search the issue repository to ensure you are reporting a new issue
-
Reproduce the issue after disabling all extensions except the AL Language extension
-
Simplify your code around the issue to better isolate the problem
- Dominant language
- PowerShell
- Stars
- 881
- Forks
- 285
- Avg merge
- 3d 36m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/AL
-
accepted al-tools bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
AL 18.0.2732683 regression: System.Drawing types cannot be resolved from assembly probing paths Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
accepted packaging
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
accepted
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
compiler/runtime
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
objectionary/eo#8869 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
EricSpencer00/Resilient#4824 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/jeo-maven-plugin#1758 ·
-
generics
Difficulty 2/5 1-3 hours Newbie friendliness 82/100