Sign in Join

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

Mailing lists / fpc-pascal / 2020-05

Empty Set in constants in generics

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Ryan Joseph

Should generics accept empty sets as constants? I think they should and this is a bug but I wanted to ask first.

========================

{$mode objfpc}
program test;
type
  TItem = (A, B, C);
  TItems = set of TItem;
  generic GType<const T: TItems> = class
  end;
const
  TOtherItems = [];   // no problems here
type
  // error: Incompatible types: got "Empty Set" expected "TItems"
  TType = specialize GType<[]>;
begin
end.

Regards,
Ryan Joseph

Sven Barth
to Ryan Joseph

Ryan Joseph via fpc-pascal schrieb am
Mo., 4. Mai 2020, 18:48:

Show quoted text 25 lines
Should generics accept empty sets as constants? I think they should and this is a bug but I wanted to ask first. ======================== {$mode objfpc} program test; type TItem = (A, B, C); TItems = set of TItem; generic GType<const T: TItems> = class end; const TOtherItems = []; // no problems here type // error: Incompatible types: got "Empty Set" expected "TItems" TType = specialize GType<[]>; begin end.

Yes, they should indeed.

Regards,
Sven