CodeTools does not respect $SCOPEDENUM
Original Reporter info from Mantis: PascalDragon @PascalDragon
-
Reporter name: Sven Barth
Original Reporter info from Mantis: PascalDragon @PascalDragon
- Reporter name: Sven Barth
Description:
Since FPC 2.6.0 the local modifier $SCOPEDENUM (ON/OFF, +/-) is supported which allows to specifiy enums in a single unit that contain the same identifiers. These identifiers must be used with a complete name though.
E.g.
type
TEnum1 = (
Value1,
Value2,
Value3
);
var
e1: TEnum1;
begin
e1 := TEnum1.Value1;
e1 := Value1; // This will generate an "identifier not found" error or a "expected TEnum, but got SomeOtherType" if another type (even a non scoped enum value!) exists
end;
This means that CodeTools and here most importantly "ofall" for case-statements must check whether the enum is a scoped one or not.
Note: if a scoped enum is defined as a nested type of a class/record then the full name including the class/record must be used! (nested unscoped enums will conflict with non-nested unscoped enums)
Additional information:
Here is another example:
program scopedenums;
{$mode objfpc}
type
{$scopedenums on}
TEnum1 = (
Value1,
Value2,
Value3
);
TEnum2 = (
Value1,
Value2,
Value3
);
{$scopedenums off}
TEnum3 = (
Value1,
Value2,
Value3
);
var
e1: TEnum1;
e2: TEnum2;
e3: TEnum3;
begin
case e1 ofall
case e2 ofall
case e3 ofall
end.
In case of "case e1" and "case e2" pressing Ctrl+J after the "ofall" should result in
case e1 of
TEnum1.Value1: ;
TEnum1.Value2: ;
TEnum1.Value3: ;
end;
and
case e2 of
TEnum2.Value1: ;
TEnum2.Value2: ;
TEnum2.Value3: ;
end;
respectively while for e3 it should stay the same.
Mantis conversion info:
- Mantis ID: 22283
- Version: 1.1 (SVN)
- Fixed in version: 1.5 (SVN)