Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-04

Inline scoped enums

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Роман
How can this code
{$scopedenums on}
type
	Bar = set of (A, B, C);
refer to A, B, C?
Роман
Show quoted text 7 lines
> How can this code > {$scopedenums on} > type > Bar = set of (A, B, C); > refer to A, B, C? Bar.A

Actually Bar.A won't work, notice the "set of".
Same problem with var x: (a, b, c).
I wonder could they make such code to not compile at all...

Alexander Grotewohl
to Роман

indeed. there are other type declarations where 'set of' is valid, so maybe it inadvertently piggybacks on those

to correct the code.. something like:

{$scopedenums on}
type
   bar = (a, b, c);
var
   foo: set of bar;
begin
   foo:=[bar.a, bar.c];
   if bar.a in foo then
     writeln('yay obscure pascal features! :)');
end.
Роман wrote 13 lines
>> How can this code >> {$scopedenums on} >> type >>     Bar = set of (A, B, C); >> refer to A, B, C? > Bar.A > Actually Bar.A won't work, notice the "set of". Same problem with var x: (a, b, c). I wonder could they make such code to not compile at all... _______________________________________________ fpc-pascal maillist  -  http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Mattias Gaertner
to Mattias Gaertner
Show quoted text 19 lines
On Sat, 7 Apr 2018 08:52:43 +0200 Mattias Gaertner wrote: > On Fri, 6 Apr 2018 21:38:59 +0300 > Роман via fpc-pascal wrote: > > > How can this code > > {$scopedenums on} > > type > > Bar = set of (A, B, C); > > refer to A, B, C? > > Bar.A I correct myself: Bar.A is wrong. A is right. It's a bug in FPC.

It's also buggy in Delphi. As a nested type in a class you cannot access A, neither with scopedenums of or on:

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.

Mattias

Mattias