Modify

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#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, 17 years ago

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, 17 years ago

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, 17 years ago

"True" and "False" may be any logical expressions, VBScript code

WScript.Echo vbTrue Or vbTrue And vbFalse

Return True

comment:4 by amel27, 17 years ago

in others languages this expression return True too
that is, it is AutoIT feature?

comment:5 by Valik, 17 years ago

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.