#3715 closed Bug (Fixed)
Au3Stripper is unable to parse some ternary expressions
Reported by: | anonymous | Owned by: | Jos |
---|---|---|---|
Milestone: | Component: | Other | |
Version: | 3.3.14.5 | Severity: | None |
Keywords: | Au3Stripper, ternary expressions | Cc: |
Description
Sorry if there is a ticket already to this issue but I didn't find it.
Tested on newest SciTE4AutoIt (and downloading Au3Stripper separately).
The docs say... and I quote: "Do not complain if using Au3Stripper prevented the script from working correctly" but this seriously has to be a joke, if not you may as well close this ticket.
Anyway...
As the title says Au3Stripper doesn't work on badly formatted ternary operations.
What do I mean by "badly"? Not using spaces after the : operator.
See these examples:
Example 1 - No error (see *_stripped.au3)
#AutoIt3Wrapper_Run_Au3Stripper=y Local $a = 1 Local $b = 2 Local $c = 3 MsgBox(0, 0, $a ? $b : $c)
Example 1 - Stripped Code:
Local $a = 1 Local $b = 2 Local $c = 3 MsgBox(0, 0, $a ? $b : $c)
No errors during compilation.
Example 2 - Error (see *_stripped.au3)
#AutoIt3Wrapper_Run_Au3Stripper=y Local $a = 1 Local $b = 2 Local $c = 3 MsgBox(0, 0, $a ? $b :$c)
Example 2 Stripped Code:
Local $a = 1 Local $b = 2 MsgBox(0, 0, $a ? $b :$c)
Error thrown:
warning: $c: possibly used before declaration. error: $c: undeclared global variable.
Note that the interpreter doesn't mind this style (talking about the unstripped version) at all, it parses it without any hickups.
However, if you declare and define your variables like this (leaving out the MsgBox line to keep it short)
Local $a = 1, $b = 2, $c = 3
or this
Local $a = 1, $b = 2 $c = 3
it works with the stripper, but not if you add the scope to it:
Local $a = 1, $b = 2 Local $c = 3
Also there is another error which removes the : completely, but you need to apply parameters (I don't know if these are the ones necessary or if it works with some of them (doesn't work for none))
Original
#AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm Local $a = 1, $b = 2, $c = 3 MsgBox(0, 0, $a ? $b: $c)
Stripped
Local $0 = 1, $1 = 2, $2 = 3 MsgBox(0, 0, $0 ? $3 $2)
Repeting the first error with parameters:
First error (bad referencing this time)
#AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm Local $a = 1, $b = 2, $c = 3 MsgBox(0, 0, $a ? $b :$c)
Local $0 = 1, $1 = 2, $2 = 3 MsgBox(0, 0, $0 ? $1 :$c)
However this time (if you don't have a space after the : ) you can't solve it with not using a scope. It still references the original variable whose name was replaced by the stripper with $3.
Attachments (0)
Change History (6)
comment:1 Changed 5 years ago by anonymous
comment:2 Changed 5 years ago by Jos
Please try to current Beta version and see if that solves all your failing scenarios:
https://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/Au3Stripper.exe
Thanks for the report,
Jos
comment:3 Changed 5 years ago by Jos
- Owner set to Jos
- Status changed from new to assigned
comment:4 follow-up: ↓ 6 Changed 5 years ago by anonymous
I tested all three variations (front space missing, back space missing, both spaces missing) and all of them were stripped correctly and did not cause any errors while compiling reported by Au3Check.
Thank you very much, the beta version solved this issue.
Hopefully it will be merged into the new release.
comment:5 Changed 5 years ago by Jos
- Resolution set to Fixed
- Status changed from assigned to closed
comment:6 in reply to: ↑ 4 Changed 5 years ago by Jos
Replying to anonymous:
Hopefully it will be merged into the new release.
Thanks for testing and it will be in the next version of SciTE4AutoIt3 installer.
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.
Oh and if you remove both spaces and use the parameters provided (in my example) it eats up one part of the ternary expression: