Modify

Opened 10 years ago

Closed 10 years ago

#3200 closed Bug (No Bug)

Ternary operator for functions

Reported by: anonymous Owned by:
Milestone: Component: Au3Check
Version: 3.3.14.2 Severity: None
Keywords: Ternary Cc:

Description

It looks like Au3Check error, because AutoIt runs this script without errors

$v = 0
$v ? _F1() : _F0()

Func _F1()
  MsgBox(0, "", 1)
EndFunc

Func _F0()
  MsgBox(0, "", 0)
EndFunc
>Running AU3Check (3.3.14.2)  from:d:\AutoIt3  input:D:\test.au3
"D:\test.au3"(2,19) : error: Statement cannot be just an expression.
$v ? _F1() : _F0()
~~~~~~~~~~~~~~~~~~^
D:\test.au3 - 1 error(s), 0 warning(s)
!>17:39:20 AU3Check ended. Press F4 to jump to next error.rc:2

Attachments (0)

Change History (7)

comment:1 by mLipok, 10 years ago

From the help file:

Conditionally chooses one of two responses based on the result of an expression.

Where you store the responses ?

Your example is correct when it comes to that AutoIt offer such a possibility.
It is also not correct when it comes to assumptions as to the use of Ternary Operators as such.

comment:2 by anonymous, 10 years ago

This is not an error for AutoIt, why this is an error for Au3check?

comment:3 by J-Paul Mesnage, 10 years ago

In this special case Au3Check make a little more than AutoIt as the statement as no meaning Nothing can be stored

comment:4 by anonymous, 10 years ago

I don't need "a little more". I need like AutoIt. No more.
If you need "a little more", please, add the option.

comment:5 by J-Paul Mesnage, 10 years ago

Au3Check flag Something meaninless
AutoIt produce error if invalid
In this case it can be legal if for instance a function is called changing for instance a global variable or a byref variable.
In this case a dummy variable to store the result of the ternary operation will be needed to have a really working script

in reply to:  4 comment:6 by Jos, 10 years ago

Replying to anonymous:

I don't need "a little more". I need like AutoIt. No more.
If you need "a little more", please, add the option.

Please simply do not use au3check in case you really feel this strong about it.

Jos

comment:7 by Jos, 10 years ago

Resolution: No Bug
Status: newclosed

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.