View Issue Details

IDProjectCategoryView StatusLast Update
0022283LazarusIDEpublic2016-01-02 22:47
ReporterSven BarthAssigned ToOndrej Pokorny 
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version1.5 (SVN) 
Summary0022283: CodeTools does not respect $SCOPEDENUM
DescriptionSince 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 InformationHere 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.
TagsNo tags attached.
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Activities

Ondrej Pokorny

2016-01-02 22:47

developer   ~0088534

Fixed in the meantime (is already in 1.6).

Issue History

Date Modified Username Field Change
2012-06-16 21:34 Sven Barth New Issue
2012-06-16 21:34 Sven Barth LazTarget => -
2012-06-16 22:45 Mattias Gaertner Status new => assigned
2012-06-16 22:45 Mattias Gaertner Assigned To => Mattias Gaertner
2016-01-02 22:47 Ondrej Pokorny Note Added: 0088534
2016-01-02 22:47 Ondrej Pokorny Status assigned => resolved
2016-01-02 22:47 Ondrej Pokorny Fixed in Version => 1.5 (SVN)
2016-01-02 22:47 Ondrej Pokorny Resolution open => fixed
2016-01-02 22:47 Ondrej Pokorny Assigned To Mattias Gaertner => Ondrej Pokorny