nielsAD / lape

Scripting engine with Pascal-like syntax for FPC and Delphi
112 stars 26 forks source link

Explicitly scoped enums bug #180

Closed slackydev closed 2 years ago

slackydev commented 2 years ago

So explicitly scoped enums have an issue.

type
  EMyEnum = (meFoo=1, meBar, meBaz);

begin
  WriteLn(meFoo,', ', meBar, ', ', meBaz); // works as expected
  WriteLn(EMyEnum.meBaz); // this will be offset by -1 and be linked to `meBar`
  WriteLn(EMyEnum.meFoo); // this will fail compilation
end.

Unknown declaration "meFoo" at line ...

So given an start offset of say 3, none of them will even be linked when prefixing with enumtype, so all will cause compilation error in such a case.


PS: This issue wasn't always equal to this, running in an old Simba, using god knows which version of lape I get this output This lape version predates this: https://github.com/nielsAD/lape/tree/25a0b05ff7953af8c01ffc81ea4528ec7bfcae73

meBar, meBaz, InvalidEnum(3)
InvalidEnum(3)
meBar

At least not a compilation error.