foralex / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Variable scope not always respected #201

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

picoc> while(1) {
     >   int e = getchar();
     >   if(e == 0x20) break;
     > }
f
d
t

picoc> int e;
             ^
:5: 'e' is already defined

What is the expected output? What do you see instead?
Variable "e" should have no meaning outside of the while() block, however, it 
is still defined when execution continues past the block.

What version of the product are you using? On what operating system?
This happens both on v2.1 and on r608, both on x86-64 Linux 3.14 with GCC 
4.8.2, and on a platform with SH4 CPU I'm porting PicoC to (with great 
success), and for which I cross-compile using GCC 4.8.2 too.

Please provide any additional information below.
This also appears to happen with if blocks, and probably with for blocks too...

picoc> if(1) {
     >   int a = 6;
     > }
     > int a;
             ^
:4: 'a' is already defined
picoc>

Original issue reported on code.google.com by gbl0...@gmail.com on 30 Jan 2015 at 6:43