[fpc-pascal] precedence "is" and "and"
Mattias Gaertner
nc-gaertnma at netcologne.de
Sat Dec 8 20:38:23 CET 2018
Hi,
According to the docs, the "is" operator is fourth level, the "and" is
second level, so the "and" must be computed before the "is". But it
seems fpc treats "is" and "and" as same level:
{$mode objfpc}
uses Classes;
var
b: boolean;
o: TObject;
begin
// this compiles, but should fail:
if o is TComponent and b then ;
// this fails, correct
if b and o is TComponent then ;
// for completeness, this fails:
if TComponent and b then ;
end.
The strange thing, is that the Delphi compiler works as fpc and the
Delphi docs says the same as the fpc docs:
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Expressions_(Delphi)#Operator_Precedence
Mattias
More information about the fpc-pascal
mailing list