Unexpected compiler error

I created a simple set (enum):

Type
  SSet = (
    sOne,
    sTwo,
    sThree,
    sFour
  );

  TSet = set of SSet;

Then I wrote a test. The code snippet below works fine unless I remove the “: TSet” declaration. This is inconsistent since the [SSet.sThree] indicates a set (), so the type shouldn’t need stating.

  var s1: TSet := [SSet.sThree];
  var s2 := [SSet.sOne, SSet.sThree];
  var ix := s1 * s2;

Omitting it throws:

Error 1 (E64) Type mismatch, cannot find operator to evaluate “array of SSet” * “array of SSet” …

Further, ix is invisible to IntelliSence. The following compiles correctly, but I had to escape IntelliSence and manually type ix:

  if (SSet.sThree in ix) then
    MessageBox.Show('OK');

The issue here is that [] is used for both array constants and sets. Type inference can only have one type so the compiler picks array, since it’s a lot more common than sets. As you found already, the fix is simple, a type or a cast on the right side

Thank you. Fair enough. As per your other post, it seems best to avoid Delphi-style sets in Oxygene, which eliminates the question completely.