Why is this an issue?
Omitting the type for inline variable declarations has a few downsides, including:
- The lack of type information can make code harder to follow and understand at a glance.
- Type expansion that occurs during type inference can lead to unexpected inferred types.
- Wrapper types relying on implicit type conversions will not have those conversions invoked.
How to fix it
Explicitly specify the variable's type:
procedure Example;
begin
var Foo := 123;
end;
procedure Example;
begin
var Foo: Integer := 123;
end;
Resources