Jump to content
Sign in to follow this  
Exit

Au3Check bug ?

Recommended Posts

All following three scripts generate an Au3Check error.
Is this an Au3Check bug or did I miss something?

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
Local $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

image.png.c53e51f02d1578401871de7ab7624644.png

 

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
    Local $rc
    $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

image.png.117eb371102ccc948c1f7066cebbf495.png

 

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
    $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

image.png.07c543a024ffa72995e500e6a1057034.png


App: Au3toCmd              UDF: _SingleScript()                             

Share this post


Link to post
Share on other sites

It actually tells you what the issue is, the variable is declared but not used, if you use it you won't have an issue.  Your last example you didn't declare the variable or use it within the function.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
    Local $rc = 1 ? Beep() : ""
    ConsoleWrite($rc & @CRLF)
EndFunc   ;==>_test

_test()

 

Edited by Subz

Share this post


Link to post
Share on other sites

As the ternary operator seems to have a higher precedence than the assignment I rather think of a misuse in this case

Func _test()
   $rc = "whatever" ? Beep() : ""
   ConsoleWrite($rc & @CRLF)
EndFunc   ;==>_test

_test()

This code consolewrites 1 which is the return value of beep because the conditional "whatever" is considered as true - IMHO

Share this post


Link to post
Share on other sites
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
#forcedef $rc
#forceref $rc
    $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

Works like a charm.

EDIT: inelegant "solution", see correction below

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
41 minutes ago, jchd said:
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
#forcedef $rc
#forceref $rc
    $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

Works like a charm.

OK, that's one way to get around the bug.
There is a simpler one though:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
Global $rc
Func _test()
    $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

But both are emergency solutions.
The ternary assignment is actually not that complex that Au3Check should not handle it.
So it seems to be an Au3Check bug.


App: Au3toCmd              UDF: _SingleScript()                             

Share this post


Link to post
Share on other sites

Using global pollutes the variable space IMHO.  The less globals, the less problems.

And yes this is a minor Au3Check issue with the ternary op.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

This is not a bug in au3check.

The variable $rc in you function is initialised but never read/used, hence the warning.  In your test function $rc is completely redundant. 

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
Local $rc = 1 ? Beep() : ""
EndFunc   ;==>_test

_test()

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
13 minutes ago, Exit said:

The ternary assignment is actually not that complex that Au3Check should not handle it.

So you are willing to take up the challenge and fix au3check for everybody? ;)  

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Bowmore You're right, the issue isn't precisely that.  There are still actual minor issues with ?: in Au3Check if I recall correctly albeit I don't remember which use case right now.

Here it's rather the use of a pointless ternary assignment that's causing the warning.  I believe the OP's original code is more involved but boils down to the example posted.

Also the code can be logically simplified:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Func _test()
    Local $rc = 1 ? Beep() : ""
    #forceref $rc
EndFunc   ;==>_test

_test()

 


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
15 minutes ago, Exit said:

@Jos  Jos, I would like to help, but you overestimate my ability by far. :thumbsup:

.. but you were the one stating it should be 'trivial"...no?


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
11 minutes ago, jchd said:

There are still actual minor issues with ?: in Au3Check if I recall correctly albeit I don't remember which use case right now.

You mean this one? https://www.autoitscript.com/trac/autoit/ticket/3624

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
4 minutes ago, Jos said:

but you were the one stating it should be 'trivial"...no?

and the trap closed on the reckless ...


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
3 minutes ago, Jos said:

You mean this one?

No it was more along a real-world involved statement, but can't find it.  Zero importance anyway.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
4 minutes ago, Jos said:

.. but you were the one stating it should be 'trivial"...no?

No, I just said that the ternary assignment is actually not that complex


App: Au3toCmd              UDF: _SingleScript()                             

Share this post


Link to post
Share on other sites
8 minutes ago, mikell said:

The issue seems to be that Au3check isn't able to say 'this code is inconsistent'

Correct, Ternary type statements were introduced much later and all we (i) have done in au3check is to tolerate the ternary statements, so trying to avoid wrong warnings/errors, but never tried to implement checking the validity as they aren't as easy as some of us think they are. :) 
I have said it already many times before, but my brains aren't build to think in the way YACC & FLEX work, so I am trying to stay out of that code when there is no real problem.

Jos 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...