Mattias Gaertner via fpc-pascal
2018-12-08 19:38:23 UTC
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
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepa
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
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepa