Modify

Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#2612 closed Bug (Fixed)

Au3Check bugs on function reference when function takes byref parameter

Reported by: jchd18 Owned by: Jpm
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 Changed 10 years ago by anonymous

Not a bug, syntax error.

Use:

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

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

comment:2 Changed 10 years ago by guinness

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

comment:3 Changed 10 years ago by guinness

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

If You declare the function before no error ...

comment:5 Changed 10 years ago by jchd18

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

comment:6 Changed 10 years ago by Jpm

  • Milestone set to 3.3.11.5
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [10077] in version: 3.3.11.5

comment:7 Changed 8 years ago by anonymous to

>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.

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 owner will remain Jpm.
Author


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

 
Note: See TracTickets for help on using tickets.