Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for AA0206 when using DateTime.Date() or DateTime.Time() #7874

Open
4 of 6 tasks
wbor-nvt opened this issue Oct 16, 2024 · 0 comments
Open
4 of 6 tasks

Comments

@wbor-nvt
Copy link

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

Image

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:
    • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants