Missing compiler error on using 0T for time calculations
1. Describe the bug
When using 0T for time calculations, a compile error is missing to avoid a runtime error in BC.
2. To Reproduce Steps to reproduce the behavior:
Write this code - it does not raise a warning or error:
local procedure TimeTest()
var
MillisecondsSinceMidnight: Integer;
begin
MillisecondsSinceMidnight := Time - 0T;
Message(Format(MillisecondsSinceMidnight));
end;
But when we run it in the client, we get the following runtime error:
The date is not valid.
Why date, I don't know ... this is something for the platform team ;-)
However, the correct code would have been:
local procedure TimeTest()
var
MillisecondsSinceMidnight: Integer;
begin
MillisecondsSinceMidnight := Time - 000000T;
Message(Format(MillisecondsSinceMidnight));
end;
3. Expected behavior
Raise a compiler error on calculating with 0T. The error should instruct to use 000000T instead.
4. Actual behavior No warning or error.
5. Versions:
- AL Language: 12.1.887908
- Visual Studio Code: 1.84.1
- Business Central: 23.0
This looks like it has been overlooked, @BazookaMusic - can you help/forward?
@NKarolak Oops, thanks for the ping!We should triage this. It should either fail compilation or we should make it work.
Just FYI, related standard issue but in AL code https://github.com/microsoft/BCApps/pull/444
Just to highlight here; 0T and 00T are different valid values, neither should fail compilation as the values format to an empty string and midnight respectively. Noticing that the constant NULL time should not be used in a subtraction would be a nice Codecop error though.