logical operator AND evaluates right operand although left operand is FALSE
According to documentation
boolean expressions are evaluated with short-circuit evaluation. This means that from the moment the result of the complete expression is known, evaluation is stopped and the result is returned.
In the following example, the right operand of AND gets evaluated although the left operand is FALSE and therefore the operation result is already known (FALSE). Using the {$B-} directive does not enable short circuit boolean evaluation.
procedure Foo(x: OleVariant);
begin
if (not VarIsEmptyParam(x)) and (VarType(x) = varBoolean) and (Boolean(x) = true) then
; //do something
end;
begin
Foo(EmptyParam); // throws invalid variant operation Error = boolean
// this means (VarType(x) = varBoolean) was evaluated although (not VarIsEmptyParam(x)) is FALSE and
// (Boolean(x) = true) was evaluated although (VarType(x) = varBoolean) is FALSE
end.