Modify

Opened 11 years ago

Closed 11 years ago

#3096 closed Bug (No Bug)

Confusing error message when initializing default argument with undeclared variable

Reported by: Bo-Cheng Jhan Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.0 Severity: None
Keywords: error message, default argument, undeclared variable Cc:

Description

On this example:

; Begin of test.au3
test(1)

Func test($x, $y = $z)
; $z is not declared.
EndFunc
; End of test.au3

This script causes the following error:

test(1)
test(1) ERROR
Error: Variable used without being declared.

However, it is no "variable" found in this line. The actual problem is in $z, so the following error message will be more readable:

Func test($x, $y = $z)
Func test($x, $y = ERROR
Error: Variable used without being declared.

Attachments (0)

Change History (7)

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

If you use Scite which launch by default AU3Check you get the right line

in reply to:  1 comment:2 by Bo-Cheng Jhan, 11 years ago

Replying to Jpm:

If you use Scite which launch by default AU3Check you get the right line

Oh, yes. But I'm used to editting scripts in Notepad and run it by clicking au3 files.
BTW, the compiled exe reports the same wrong line number (line 1).

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

The AutoIT compiler and AutoIt have the same code so it is normal that you get the same result

comment:4 by anonymous, 11 years ago

Shouldn't the compiler/AutoIt3.exe give the correct line number for the error message? If you just run the script, you'd be looking at the line where test is called, and not at the actual line with the error. You shouldn't have to rely on Au3Check to tell you where the error is, AutoIt should tell you that, especially in an uncompiled script.

comment:5 by jchd18, 11 years ago

You're supposed to run (compiled or not) only syntactically correct programs and this is exactly why Au3Check exists in the first place.
Now suppose the function is only used during yearly inventory: all you have gained in not running Au3Check is spread easy to fix bug(s) in the wild.

The interpretor is not meant to carry the useless code needed to check all issues caught by specific code inside Au3Check.

Other languages have comparable tools, e.g. valgrind, CodeSonar, ... but what you seem to expect is something like clang, which is a much, much bigger project.

in reply to:  5 comment:6 by Bo-Cheng Jhan, 11 years ago

Replying to jchd18:

You're supposed to run (compiled or not) only syntactically correct programs and this is exactly why Au3Check exists in the first place.
Now suppose the function is only used during yearly inventory: all you have gained in not running Au3Check is spread easy to fix bug(s) in the wild.

Thanks for comment by jchd18. Actually, I didn't understand functions of other directories and exe in AutoIt3/ before.
I'll survey how to use Au3Check via command line (.bat file) first. I like to compile/run programs by commands, and I feel inconvenience using graphical tools like Visual Studio. However, I appreciate the simplicity of GUI design in AutoIt.

comment:7 by Jos, 11 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.