Modify

#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 J-Paul Mesnage, on Nov 11, 2008 at 5:54:15 AM

Resolution: No Bug
Status: newclosed

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

comment:2 by Valik, 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 amel27, 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 amel27, 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 Valik, 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.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.