Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#3879 closed Bug (Fixed)

Dim doesn't change the type of Map to Array

Reported by: jchd18 Owned by: Jon
Milestone: 3.3.16.1 Component: AutoIt
Version: 3.3.16.0 Severity: None
Keywords: Cc:

Description

Given a variable $v and for all AutoIt datatypes except Map, using Dim to change $v into an Array works fine.

Local $m[]		; a Map
Local $a[5]		; an Array

Local $types = [ _
	$m, _
	$a, _
	8, _
	8888888888888888, _
	"xyz", _
	Binary(12), _
	Ptr(555), _
	DllStructCreate("long"), _
	MsgBox, _
	_myFct, _
	ObjCreate("shell.application"), _
	Null, _
	True _
]

Func _myFct()
EndFunc

For $v In $types
	ConsoleWrite("$v declared as " & VarGetType($v) & @LF)
	Dim $v[3]
	ConsoleWrite("$v turned to a " & VarGetType($v) & @LF & @LF)
Next

Dim is important when you get a ByRef variable of unknown type passed to a function, which you need to (re)turn into an Array loaded with data. It's even the only use case of Dim in AutoIt.

For a real-world use case where this can cause a serious bug, see https://www.autoitscript.com/forum/topic/208003-storing-gui-objects-in-an-array-error-subscript-used-on-non-accessible-variable/?do=findComment&comment=1500761

Attachments (0)

Change History (3)

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

Owner: set to J-Paul Mesnage
Status: newassigned

Thanks,
Fix sent to Jon

comment:2 by Jon, 4 years ago

Milestone: 3.3.15.6
Owner: changed from J-Paul Mesnage to Jon
Resolution: Fixed
Status: assignedclosed

Fixed by revision [12733] in version: 3.3.15.6

comment:3 by Jon, 4 years ago

Milestone: 3.3.15.63.3.16.1

Fixed by revision [12734] in version: 3.3.16.1

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


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