Inline scoped enums bug?

Inline scoped enums bug?

As a nested type in a class you cannot access A:

type
TC = class
public
type TBar = set of (A, B, C);
end;

Neither A, nor TBar.A, nor TC.TBar.A works in Delphi 10.2.

Comments

  1. Works fine here in 10.2.3:

    program Project135;

    {$APPTYPE CONSOLE}

    {$R *.res}

    uses
    System.SysUtils;

    type
    TC = class
    public
    type TBar = set of (A, B, C);
    end;

    var
    x: TC.TBar;

    begin
    x := [A];
    end.

    ReplyDelete
  2. That is not a type declaration?
    How about this style of declaration?

    type
    TC = class
    public type
    TBar = (A, B, C) ;
    TBarSet = set of TBar;
    end;
    ...
    var
    tb: TC.TBarSet;
    begin
    tb := [TC.TBar.A, TC.TBar.B];

    ReplyDelete
  3. I think it’s fairly safe to answer any question with the title like “is this a compiler bug?” with “no. pebkac”, without reading the actual question. :-)

    ReplyDelete
  4. Compiling that under {$SCOPEDENUMS ON} makes little sense to me, since you're requesting the A, B and C identifiers to be scoped to something anonymous, and therefore, that you inherently can't qualify with. Ergo, an inability to actually reference A, B C is arguably technically correct....

    ReplyDelete

Post a Comment