False positive for AA0206 when using DateTime.Date() or DateTime.Time()
Please include the following with each issue:
1. Describe the bug
When using the new .Date() and .Time() functions of a DateTime variable, the AL compiler throws a warning that the DateTime variable is not used.
The variable 'NewDateTime' is initialized but not used. AL(AA0206)
2. To Reproduce Steps to reproduce the behavior:
local procedure TestNewDateTime_WithWarning()
var
NewDateTime: DateTime;
NewDate: Date;
NewTime: Time;
begin
NewDateTime := CurrentDateTime();
NewDate := NewDateTime.Date();
NewTime := NewDateTime.Time();
end;
local procedure TestNewDateTime_WithoutWarning()
var
NewDateTime: DateTime;
NewDate: Date;
NewTime: Time;
begin
NewDateTime := CurrentDateTime();
NewDate := DT2Date(NewDateTime);
NewTime := DT2Time(NewDateTime);
end;
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 Should not throw a warning as the DateTime variable has been used.
4. Actual behavior
The variable 'NewDateTime' is initialized but not used. AL(AA0206)
5. Versions:
- AL Language: v15.0.1177813
- Visual Studio Code: 1.94.2
- Business Central: 25.0
- List of Visual Studio Code extensions that you have installed:
- Operating System:
- [x] Windows
- [ ] Linux
- [ ] MacOS
Final Checklist
Please remember to do the following:
-
[x] Search the issue repository to ensure you are reporting a new issue
-
[x] Reproduce the issue after disabling all extensions except the AL Language extension
-
[x] Simplify your code around the issue to better isolate the problem
Internal work item: AB#572542
Also facing the same issue...
Also experiencing the same issue:
@krupybalu @BazookaMusic Can you please have a look? This shouldn't be hard to fix and it currently prevents partners to use these new functions.
We receive the same warning. The bug is still present in BC26. When will the bug be fixed?
@BazookaMusic Was this overlooked?
The fix for this issue has been checked in to the master branch. It is available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 27.0.33621.0 and VS Code Extension Version 16.0.1474884.
If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo