Chuck F wrote:
Waldek Hebisch wrote:
The following program ilustrates the problem (AFAIR something similar is in the todo directory). In procedure k reference to x is illegal becouse k is in the scope of second declaratin, but before the defining point. It would be easy to catch such things by tree-walk, but otherwise housekeeping is quite messy.
program scope; var x : integer; procedure p; procedure k; begin x:= x+1; end; var x : boolean; begin end; begin writeln('failed') end .
But the declaration of x itself is illegal there. It belongs between the "procedure p;" and the "procedure k;" lines. Proper indentation makes it obvious (below) or am I missing something?
Well, Extended Pascal allows mixing declarations of procedures and variables, so you can declare variables for a block just before statement part of that block. And gpc compiles the program and only warns about unused variables/procedures...