Unfortunately I can't test what is allowed in Delphi and what is not.
But the following works in fpc.
procedure Foo;
var i: integer;
procedure Nested;
var i: integer;
begin
{...}
writeln(i);
end;
begin
{...}
end;
Now, if that also works in Delphi, then I would expect that the following works too
procedure Foo;
var i: integer;
procedure Nested;
begin
{...}
var i := 123;
{...}
writeln(i);
end;
begin
{...}
end;
And suddenly it's far less noticeable, that the writeln does not refer to the outer Foo's var "i".
IMHO, that really makes increases the chances of an error in that case....
And for a maybe more likely example => the same should be happening if it wasn't a nested proc, but if there was a global var (or function, ...).
Or in any other case where an identifier can be hidden by one other of the same name.
So there are plenty of cases.
And code grows. If all procedures were really really small, then the scoping of an inline var wouldn't make any change at all. But if procs are bigger, then inline vars can hide very very well.
And please don't reply "But that is bad code" / "that abuses the feature" / "shouldn't be used like that" / ....
Because, usually inline vars are advertised to help, if code without them would be more error prone => but if the above is just "bad code" / "abuse" ...
Well, then how come that any code that
supposedly needs to be "improved" with inline vars, that such code is not equally "bad code" / "abuse" ...?
But, if it comes down, to using the tools correctly (
with or without inline vars), then what improvement do they add?
Say the "for loop" example? But if it is just that, does that really make up for the down sides?