Opened on Nov 11, 2008 at 4:32:04 AM
Closed on Nov 11, 2008 at 5:54:15 AM
Last modified on Nov 11, 2008 at 4:43:41 PM
#673 closed Bug (No Bug)
Wrong priority of logic operators
| Reported by: | amel27 | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.2.12.0 | Severity: | None |
| Keywords: | Cc: |
Description
True Or True And False
return False, but equivalent expression
True Or (True And False)
return True
Attachments (0)
Change History (5)
comment:1 by , on Nov 11, 2008 at 5:54:15 AM
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
comment:2 by , on Nov 11, 2008 at 6:31:02 AM
Just to further explain what JP said, the first expression becomes
True And False
Which is false and that's what your first test shows. Now, your second expression becomes
True Or False
because we've already established "True And False" is False. So, now that the Or operate is in play and True is part of the expression, the result is True.
Thus, as JP says, this is not a bug.
comment:3 by , on Nov 11, 2008 at 7:19:50 AM
"True" and "False" may be any logical expressions, VBScript code
WScript.Echo vbTrue Or vbTrue And vbFalse
Return True
comment:4 by , on Nov 11, 2008 at 7:39:35 AM
in others languages this expression return True too
that is, it is AutoIT feature?
comment:5 by , on Nov 11, 2008 at 4:43:41 PM
A lot of languages give the AND operator higher precedence than OR. In those languages your two statements are equivalent. However, as documented in the helpfile(AutoIt -> Language Reference -> Operators), AND and OR have the same precedence thus your statement is evaluated left-to-right in the manner I have described.

your expressions are not equivalent as they are executed left to right
the first is (True or True) and False
No BUG