Modify

Opened 20 months ago

Last modified 10 months ago

#3953 assigned Bug

missing bracket error when using ternary operator or OR operator inside array definition

Reported by: AspirinJunkie Owned by: Jon
Milestone: Component: AutoIt
Version: 3.3.16.0 Severity: None
Keywords: ternary bracket Cc:

Description (last modified by mLipok)

When using a ternary operator inside a direct array definition, an error is thrown at runtime when the if branch is applied:

; no error thrown
Global $A = [ 1 > 2  ? 1 : 2 ] ; else path
Global $A = [ 2 < 1  ? 2 : 1 ] ; else path
Global $A = [ 1 <> 1 ? 1 : 2 ] ; else path
Global $A = [ False  ? 1 : 2 ] ; else path

; error "Missing right bracket ')' in expression."
Global $A = [ 2 > 1 ? 2 : 1 ] ; if path
Global $A = [ 1 < 2 ? 1 : 2 ] ; if path
Global $A = [ 1 = 1 ? 1 : 2 ] ; if path
Global $A = [ True  ? 1 : 2 ] ; if path

A workaround would be to add a parenthesis around the expression.
Nevertheless, there seems to be a parsing problem here.

Attachments (0)

Change History (7)

comment:1 Changed 20 months ago by Jos

Yep, that is why this comment is in the helpfile:

Remarks
This Conditional operator allows a binary choice to be executed without the overhead of an
If...Else...EndIf structure.

Although not necessary in all cases, it is strongly recommended that the 3 elements are enclosed in parentheses.

"

comment:2 Changed 20 months ago by Jpm

  • Owner set to Jpm
  • Status changed from new to assigned

Thanks
Fix sent to Jon for next beta

comment:3 Changed 20 months ago by mLipok

  • Description modified (diff)

comment:4 Changed 19 months ago by anonymous

Info (if this isn't already part of the fix):

Global $a = [1 And 2] ; I'm ok :)
Global $b = [1 Or 2] ; I'm not ok :(

comment:5 Changed 19 months ago by Jpm

  • Summary changed from missing bracket error when using ternary operator inside array definition to missing bracket error when using ternary operator or OR operator inside array definition

Thanks
That's another pb not related with ternary operator

comment:6 Changed 19 months ago by Jpm

a new fix sent to jon

comment:7 Changed 10 months ago by Jpm

  • Owner changed from Jpm to Jon

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

Action
as assigned The owner will remain Jon.
Author


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

 
Note: See TracTickets for help on using tickets.