Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#3774 closed Bug (Fixed)

Comparisons with Null wrong for <= and >=

Reported by: AlanParry Owned by: J-Paul Mesnage
Milestone: 3.3.15.4 Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

If one runs this

if Null =  3 Then ConsoleWrite("="  & @CRLF)
if Null <  3 Then ConsoleWrite("<"  & @CRLF)
if Null >  3 Then ConsoleWrite(">"  & @CRLF)
if Null <= 3 Then ConsoleWrite("<=" & @CRLF)
if Null >= 3 Then ConsoleWrite(">=" & @CRLF)
if Null <> 3 Then ConsoleWrite("<>" & @CRLF)
if Null == 3 Then ConsoleWrite("==" & @CRLF)

then <= and >= are True, which can't be what's expected. Why would <= be true when < and = are both false?

Has a <= b been implemented as Not(a > b) perhaps? That may be the problem.

(Also the result for <> is questionable as some other languages would give that as false, but I am happy with autoit's choice in that case, and changing <> is probably a script breaker)

Tested on 3.3.14.5 and 3.3.15.3

Alan

Attachments (0)

Change History (3)

comment:1 by J-Paul Mesnage, 6 years ago

Hi,
In fact the doc is wrong
Null is a special keyword and the comparison is only true if the variable is affected to Null
see the following

Local $i = Null
if Null =  $i Then ConsoleWrite("= Null"  & @CRLF)
if Null =  "" Then ConsoleWrite("="  & @CRLF)
if Null =  0 Then ConsoleWrite("="  & @CRLF)

I will fix the doc

comment:2 by J-Paul Mesnage, 6 years ago

Milestone: 3.3.15.4
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12361] in version: 3.3.15.4

comment:3 by AlanParry, 6 years ago

Hi,
I don't think this is a docucmentation issue.
Why does either of

if Null <= 3 Then ConsoleWrite("<=" & @CRLF)
if Null >= 3 Then ConsoleWrite("<=" & @CRLF)

do the ConsoleWrite - they shouldn't! These correctly don't:

if Null =  3 Then ConsoleWrite("="  & @CRLF)
if Null <  3 Then ConsoleWrite("<"  & @CRLF)
if Null >  3 Then ConsoleWrite(">"  & @CRLF)

Your examples use the = operator which does what I expect. The < and > operators also work fine, But the <= and >= operators I think are bugged.
Alan

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


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