Analyzer
LinterCop
Issue type
False positive (diagnostic fires when it shouldn't)
Rule ID
LC0083
Description
LC0083 (BuiltInDateTimeMethod) incorrectly reports a diagnostic when a built-in date/time method is called with FieldRef.Value as the argument. The suggested replacement (e.g. MyFieldRef.Value.Date()) is invalid because FieldRef.Value returns the AL wildcard/dynamic type Joker in the SDK, which does not expose the new .Date(), .Time(), .Day(), etc. extension methods.
Root cause
- FieldRef.Value is modeled by the AL SDK as an IInvocationExpression (getter call) whose return type is NavTypeKind.Joker, not NavTypeKind.Variant.
- The existing IsVariantArgument guard only checked for Variant and therefore missed Joker, so the analyzer proceeded to emit a diagnostic.
Fix
- Extend the variant guard to also treat NavTypeKind.Joker as a skip condition (renamed to IsVariantOrJokerArgument).
- Add a dedicated IsFieldRefValueAccess guard that detects .Value accesses on a FieldRef receiver, covering both IInvocationExpression (current SDK model) and IFieldAccess (defensive against future SDK changes).
- Restrict the FieldRef guard to the Value member only (via case-insensitive IsSameName), so other FieldRef members (.Name, .GetFilter(), …) remain unaffected.
AL code to reproduce
table 50100 MyTable
{
fields
{
field(1; "My DateTime"; DateTime) { }
}
}
codeunit 50100 MyCodeunit
{
procedure MyProcedure()
var
MyTable: Record MyTable;
MyRecRef: RecordRef;
MyFieldRef: FieldRef;
MyDate: Date;
begin
MyRecRef.GetTable(MyTable);
MyFieldRef := MyRecRef.Field(1);
MyDate := DT2Date(MyFieldRef.Value); // LC0083 reported, but replacement is invalid
end;
}
Analyzer
LinterCop
Issue type
False positive (diagnostic fires when it shouldn't)
Rule ID
LC0083
Description
LC0083 (BuiltInDateTimeMethod) incorrectly reports a diagnostic when a built-in date/time method is called with FieldRef.Value as the argument. The suggested replacement (e.g. MyFieldRef.Value.Date()) is invalid because FieldRef.Value returns the AL wildcard/dynamic type Joker in the SDK, which does not expose the new .Date(), .Time(), .Day(), etc. extension methods.
Root cause
Fix
AL code to reproduce