Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#673 closed Bug (No Bug)

Wrong priority of logic operators

Reported by: amel27 Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


True Or True And False

return False, but equivalent expression

True Or (True And False)

return True

Attachments (0)

Change History (5)

comment:1 Changed 15 years ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

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

comment:2 Changed 15 years ago by Valik

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 Changed 15 years ago by amel27

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

WScript.Echo vbTrue Or vbTrue And vbFalse

Return True

comment:4 Changed 15 years ago by amel27

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

comment:5 Changed 15 years ago by Valik

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.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.