IsHandled should never be set to false #715
christophstuber
started this conversation in
New Rule
Replies: 1 comment 1 reply
-
this only applies if ishandled is a parameter, not a variable. procedure AnyThing()
var
IsHandled: Boolean;
begin
OnDoSomething(IsHandled);
if IsHandled then
exit;
IsHandled := false; // <-- should not raise a warning
OnDoAnotherThing(IsHandled)
if IsHandled then
exit;
...
end; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The IsHandled parameter should never be set to false, neither directly nor as the result of a condition evaluation or function call.
Setting IsHandled to false can cause issues, when an earlier subscriber set it to true.
This is fine:
IsHandled := true;
This is also fine:
This is obviously bad:
IsHandled := false;
This is also very dangerous:
So is this:
IsHandled := MyCondition;
Beta Was this translation helpful? Give feedback.
All reactions