AL
AL copied to clipboard
[Bug]: Compiler Error AL0122 does not handle variant correctly
1. Describe the bug Assigning date or datetime according to a condition throws Compiler Error AL0122. Using normal if statement there is no issue, but using ternary operator there is unexpected error.
2. To Reproduce
procedure FormatDate(DateValue: Text; DateFormatText: Text)
var
DateVariant: Variant;
begin
if DateValue = '' then
exit;
if DateFormatText.Contains('H') then
DateVariant := CurrentDateTime()
else
DateVariant := Today();
DateVariant := DateFormatText.Contains('H') ? CurrentDateTime() : Today();
end;
3. Expected behavior There should be no compiler errors in this procedure.
4. Actual behavior There is compiler error blocking code that actually is correct.
5. Versions:
- AL Language:
- Visual Studio Code: 1.105.1
- Business Central: BC27 RTM
- AL Language Extension: 16.2.1869542
- List of Visual Studio Code extensions that you have installed: Error Lens
- Operating System: Windows 11