Modify

Opened 5 years ago

Closed 5 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 follow-up: Changed 5 years ago by Jpm

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

comment:2 in reply to: ↑ 1 Changed 5 years ago by Bo-Cheng Jhan

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 Changed 5 years ago by Jpm

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

comment:4 Changed 5 years ago by anonymous

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 follow-up: Changed 5 years ago by 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.

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.

comment:6 in reply to: ↑ 5 Changed 5 years ago by Bo-Cheng Jhan

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 Changed 5 years ago by Jos

  • Resolution set to No Bug
  • Status changed from new to closed

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 closed The ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.