Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Language    [ Add a report in this area ]  
Report #:  140311   Status: Reported
[Regression] Cannot use ord()-defined enum values
Project:  Delphi Build #:  24.0.25048.9432
Version:    21.0 Submitted By:   Lutz Ristau
Report Type:  Basic functionality failure Date Reported:  2/7/2017 4:13:00 AM
Severity:    Commonly encountered problem Last Updated: 2/7/2017 4:08:59 AM
Platform:    32 Bit Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
In "RAD Studio Berlin 10.1 Update 2", declaring an Enum by using the ordinal value of another enum is rejected by the parser:

type
  TEnum1 = (name1, ....);

  TEnum2 = (
    Name1 = ord(TEnum1.name1),
    ....
  );

This worked in Delphi 2009.

Code Insight still understand this syntax.
Steps to Reproduce:
Create new command-line project (32-bit Windows). Use this type declarations:

program Project1;

type
  TMetafileType = (

MetafileTypeInvalid,

MetafileTypeWmf,

MetafileTypeWmfPlaceable,

MetafileTypeEmf,

MetafileTypeEmfPlusOnly,

MetafileTypeEmfPlusDual
  );

  TEmfType = (

EmfTypeEmfOnly     = ord(TMetafileType.MetafileTypeEmf),

EmfTypeEmfPlusOnly = ord(TMetafileType.MetafileTypeEmfPlusOnly),

EmfTypeEmfPlusDual = ord(TMetafileType.MetafileTypeEmfPlusDual)
  );

begin
end.

Expected: Compiles.
Actual:
dcc32 error E2003 Undeclared identifier: 'MetafileTypeEmf'
dcc32 error E2003 Undeclared identifier: 'MetafileTypeEmfPlusOnly'
dcc32 error E2003 Undeclared identifier: 'MetafileTypeEmfPlusDual'
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01