Opened 17 years ago

Last modified 14 years ago

#65 closed Bug

Au3Check gives wrong warning with Const ByRef params — at Initial Version

Reported by: Valik Owned by:
Milestone: Component: Other
Version: 3.2.10.0 Severity: None
Keywords: Au3Check Cc:

Description

The following code:

CallNonConst()
CallConst()

Func CallNonConst()
	Local $a = 32
	TakesConstByRef($a)
EndFunc

Func CallConst()
	Local Const $a = 32
	TakesConstByRef($a)
EndFunc


Func TakesConstByRef(Const ByRef $c)
	ConsoleWrite($c & @CRLF)
EndFunc

produces this error:
New AutoIt v3 Script.au3(15,37) : ERROR: TakesConstByRef() previously called with expression on Const ByRef param(s).
Func TakesConstByRef(Const ByRef $c)

New AutoIt v3 Script.au3(6,20) : REF: first call to TakesConstByRef().

TakesConstByRef($a)

New AutoIt v3 Script.au3 - 1 error(s), 0 warning(s)

The error is wrong. The code is perfectly valid. The problem is using a non-const and a const in the same script with the same function. It seems Au3Check is trying to infer something incorrectly. If you modify both examples to be identical (Either add Const to the Local it's missing from or remove it from the one where it's present) then there is no error. All Au3Check needs to worry about is making sure a variable is being passed to the ByRef statement, it doesn't need to concern itself if the variable is Const or not.

Change History (0)

Note: See TracTickets for help on using tickets.