if statements ignore paren priority - 19/07/08 08:54 AM
Few simple cases I tried..
I am a % (halfop) on #help... so most of these should have evaluated as false.. but they seem to give me true.. These were all done in #help itself (obviously) after I'd noticed a script misbehaving when I'd previously had #help exluded from the event.
What I had originally was (2) because that's readable proper syntax, now I'm stuck using (1) and it's annoying me greatly. This also means well over 50% of my other scripts (and there's a damn good many of them) will no longer function properly.
Please fire your beta testers, or at least have real programmers test these things in the future I don't see why this should have been missed. It is simple binary logic with priorities.
I am a % (halfop) on #help... so most of these should have evaluated as false.. but they seem to give me true.. These were all done in #help itself (obviously) after I'd noticed a script misbehaving when I'd previously had #help exluded from the event.
Code:
0) //if ($me ishop $chan || $me isop $chan) && $chan != #help echo true -0) For those of you that like ugly unreadable if statements, here's the stupid version which works. 1) //if (($me ishop $chan) || ($me isop $chan)) && ($chan != #help) echo true -1) Also doesn't return anything, as it should (ie it's false) Rest return true and shouldn't by basic paren priority rules. 2) //if ((($me ishop $chan) || ($me isop $chan)) && ($chan != #help)) echo true -2) any proper programmer knows it should be false 3) //if (((((($me ishop $chan) || ($me isop $chan))))) && ($chan != #help)) echo true -3) same idea as above, was to prove a point 4) //if (($me ishop $chan || $me isop $chan) && ($chan != #help)) echo true -4) again same thing, just without the extra paren priotiry on individual checks 5) //if (($me ishop $chan || $me isop $chan) && $chan != #help) echo true -5) Expanding on (4), same deal.
What I had originally was (2) because that's readable proper syntax, now I'm stuck using (1) and it's annoying me greatly. This also means well over 50% of my other scripts (and there's a damn good many of them) will no longer function properly.
Please fire your beta testers, or at least have real programmers test these things in the future I don't see why this should have been missed. It is simple binary logic with priorities.