Modify

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#2612 closed Bug (Fixed)

Au3Check bugs on function reference when function takes byref parameter

Reported by: jchd18 Owned by: J-Paul Mesnage
Milestone: 3.3.11.5 Component: Au3Check
Version: 3.3.11.2 Severity: None
Keywords: Cc:

Description

Code to trigger the issue:

Local $f = function
Local $s = 'xxx'
$f($s)

; function declaration needs to be after function reference assignment for the bug to occur
Func function(ByRef $title)
	MsgBox(0, $title, 'function invoked')
EndFunc

Au3Check gets confused and raises an error:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Users\jc\Documents\AutoMAT\tmp\fct.au3" /UserParams    
+>00:45:12 Starting AutoIt3Wrapper v.2.1.4.0 SciTE v.3.3.7.0 ;  Keyboard:0000040C  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:040C  Keyboard:0000040C  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (3.3.11.2)  from:C:\Program Files (x86)\AutoIt3\Beta
"C:\Users\jc\Documents\AutoMAT\tmp\fct.au3"(15,28) : error: function() previously called with Const or expression on ByRef param(s).
Func function(ByRef $title)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\jc\Documents\AutoMAT\tmp\fct.au3"(10,20) : REF: first call to function().
Local $f = function
~~~~~~~~~~~~~~~~~~~^
C:\Users\jc\Documents\AutoMAT\tmp\fct.au3 - 1 error(s), 0 warning(s)

Non-beta version 3.3.10.2 behaves identically.

Attachments (0)

Change History (7)

comment:1 by anonymous, 12 years ago

Not a bug, syntax error.

Use:

Local $s = 'xxx'
function($s)

Func function(ByRef $title)
	MsgBox(0, $title, 'function invoked')
EndFunc

comment:2 by guinness, 12 years ago

It's a bug! Now functions are first class objects.

comment:3 by guinness, 12 years ago

#AutoIt3Wrapper_Run_Au3Check=N ; Au3Check displays an error.

; 1st approach.
Local $sString = ''
Local $hFunc = ByRefFunc
$hFunc($sString) ; The variable is passed as a reference and not a value.
$hFunc($sString)
$hFunc($sString)
ConsoleWrite($sString & @CRLF)

; 2nd approach.
$sString = ''
ByRefFuncCall($sString, ByRefFunc)

Func ByRefFunc(ByRef $sVal) ; Changing to a pass by value and the error disappears.
	$sVal &= '__'
	Return True
EndFunc   ;==>ByRefFunc

Func ByRefFuncCall($sVal, $hFunc)
	$hFunc($sVal)
	$hFunc($sVal)
	$hFunc($sVal)
	ConsoleWrite($sVal & @CRLF)
EndFunc   ;==>ByRefFuncCall

comment:4 by J-Paul Mesnage, 12 years ago

If You declare the function before no error ...

comment:5 by jchd18, 12 years ago

I made a note of that in my first post. I look at that solution as a temporary workaround.

comment:6 by J-Paul Mesnage, 12 years ago

Milestone: 3.3.11.5
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [10077] in version: 3.3.11.5

comment:7 by anonymous to, 10 years ago

>Running AU3Check (3.3.12.0)  params:-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7  from:X:\XXX\AutoIt3
"X:\XXX...\XXX.au3"(713,59) : error: ab_update() previously called with Const or expression on ByRef param(s).
Func ab_update(ByRef $gui_id, ByRef $color)

Darn. A version mismatch. That sucks.
O well, its better than nothing I guess.

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.