Hi, I have a small test program which doesn't compile:
(file babyunit.pas)
unit babyunit;
interface
type bug=(beetle, ant);
procedure printbug(b : bug);
implementation
procedure printbug(b : bug); begin case b of beetle : writeln('beetle'); ant : writeln('ant') end end;
end.
(file baby.pas)
program baby;
uses babyunit;
var lp : bug; type insect=(beetle, ant);
begin {for lp:=bug(beetle) to bug(ant) do} { this compiles! } for lp:=beetle to ant do printbug(lp); end.
Compiler error:
gpc -g -c -w babyunit.pas gpc -g -c -w baby.pas baby.pas: In function `program_Baby': baby.pas:10: incompatible types in assignment
It looks to be a problem with having the same identifier used in two enumerations; if those two enumerations are in the same unit a more informative error message results, such as:
baby.pas:7: conflicting types for `Beetle' baby.pas:6: previous declaration of `Beetle' baby.pas:7: conflicting types for `Ant' baby.pas:6: previous declaration of `Ant' baby.pas: In function `program_Baby': baby.pas:11: incompatible types in assignment
(when type foo=(beetle,ant); is added immediately after type insect in baby.pas).
This is the most recent gpc beta snapshot compiled against the gcc 2.8.1 backend on intel/linux.
Any ideas? Is this a compiler bug?