Inline const declarations should not omit the type, as the compiler's inline type inference is inconsistent with traditional const declaration type inference.
It uses the same rules as inline var declarations, making it possible for a traditional and inline const declaration to have identical values, but different inferred types. This can cause confusion and negatively impact code readability.
procedure Example; const Foo = 123; // ShortInt Bar = [1, 2, 3]; // set of Byte begin const Beep = 123; // Integer const Boop = [1, 2, 3]; // Array of Integer end;
Declare the type of the inline const declaration explicitly:
procedure Example; const Foo = 123; // ShortInt Bar = [1, 2, 3]; // set of Byte begin const Beep = 123; // Integer const Boop = [1, 2, 3]; // Array of Integer end;
procedure Example; const Foo = 123; // ShortInt Bar = [1, 2, 3]; // set of Byte type TByteSet = set of Byte; begin const Beep: ShortInt = 123; const Boop: TByteSet = [1, 2, 3]; end;