Mattias Gaertner wrote 11 lines
Perhaps FPC treats "is" and "as" on the same level, it would explain the error ?
Show quoted text 14 lines
> >> logical (boolean) vs bitwise AND difference?
> >
> > I don't see where the bitwise should be involved here. There is no
> > integer.
> > The docs do not mention a different precedence lvl for
> > logical/bitwise "and".
>
> Because to the best of my knowledge, here isn't any difference in
> precedence, so there is nothing to explain.
Yes, that's my point. Even if bitwise "and" would play a role here, the
precedence would still be the same.
Agreed. It was Marco who brought this up ?
Show quoted text 18 lines
My hypothesis is that FPC treats 'is' and 'as' on level 2 (contrary to documentation). This is consistent with what you observe.
If 'is' is second level (i.e. the same as "as") then that would explain why it compiles, because the 'o is TComponent' will be evaluated first:
in the first line because evaluation happens from left to right, in the second line because 'is' takes precedence over 'or'.
// compiles in fpc, but not in Delphi:
if b or o is TComponent then ;
Delphi is consistent with 'is' being on a lover level: "is" is lower level, so b or O is treated first.
Again, FPC's behaviour is consistent with treating 'is' on the same level as 'as': because 'is' takes precedence over 'or', you get no error.
// does not compile, correct
if b and o is TComponent then ;
Indeed. (b and O) is evaluated first (left to right)
All is consistent with "is" and "as" being on the same level.
This is not how delphi does it.
So we adapt the documentation, or make the compiler delphi compatible.
Given that this has been in the compiler for years, I guess most people use brackets (I know I do)
Michael.