Skip to content

Fpc accepts integer as first entries in a set of char.

Fpc allows this program to compile:

program test;
{$mode objfpc} //$mode does not matter
{$H+}

const
  Chars1: set of char = [255, 254, 253, #0, #1]; 
  Chars2 = [98, '('];
  //Chars3 = ['a',98]; not allowed (as expected): Error: Incompatible types: got "ShortInt" expected "Char"
var
  Ch: Char;
begin
  if Ch in [$FF, 'A'..'Z'] then;
end.

Delphi (7) gives the expected errormessage: Error: Incompatible types: 'Integer' and 'Char'

First reported on the forum by user Avinash.

Edited by Bart
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information