16.6.1 Block scope

The scope of a variable declared in the declaration part of a block, is valid from the point of declaration until the end of the block. If a block contains a second block, in which the identifier is redeclared, then inside this block, the second declaration will be valid. Upon leaving the inner block, the first declaration is valid again. Consider the following example:

Program Demo;  
Var X : Real;  
{ X is real variable }  
Procedure NewDeclaration  
Var X : Integer;  { Redeclare X as integer}  
begin  
 // X := 1.234; {would give an error when trying to compile}  
 X := 10; { Correct assignment}  
end;  
{ From here on, X is Real again}  
begin  
 X := 2.468;  
end.

In this example, inside the procedure, X denotes an integer variable. It has its own storage space, independent of the variable X outside the procedure.