Opened on Nov 10, 2009 at 7:06:28 PM
Closed on Nov 10, 2009 at 10:51:12 PM
Last modified on Nov 11, 2009 at 6:41:06 PM
#1293 closed Bug (No Bug)
odd value returned when assigning "default" to Scripting.Dictionary
| Reported by: | Gabriel13 | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.0.0 | Severity: | None |
| Keywords: | Cc: |
Description
When the AutoIt "default" value is assigned to a Scripting.Dictionary object, and later retrieved, the result is no longer "default".
Instead, it becomes a strange "falsy" value which varGetType() identifies as "Object", yet it fails the isObj() test.
The code below illustrates what happens - I've also confirmed that this issue is present in the latest beta (3.3.1.5).
func testDictionary($v)
local $d=objCreate('Scripting.Dictionary')
$d.add('x',$v)
return $d.item('x')
endfunc
msgbox(0,default,@AutoItVersion)
local $v=default
msgbox(0,default,'"' & string($v) & '"' & @LF & varGetType($v) & @LF & isObj($v))
; returns "Default", Keyword, 0
; assign to dictionary & then retrieve
$v=testDictionary($v)
msgbox(0,default,'"' & string($v) & '"' & @LF & varGetType($v) & @LF & isObj($v))
; returns "", Object, 0
if $v then
msgbox(0,default,'truey')
else
msgbox(0,default,'falsy')
endif
; returns "falsy"
Attachments (0)
Change History (4)
comment:1 by , on Nov 10, 2009 at 10:51:12 PM
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
comment:2 by , on Nov 11, 2009 at 4:21:29 AM
My intention was to illustrate the contradictory nature of the returned value, which seems to indicate a bug of some kind.
comment:3 by , on Nov 11, 2009 at 5:14:31 AM
But there's no bug here. Default is an AutoIt keyword that has a special meaning in the context of COM. It is not, however, data that can be marshaled through a COM object or a C-like (Dll) API. In the context of COM the Default keyword behaves more or less like it does in AutoIt. That is, it tells the function to treat that parameter as being undefined and to use whatever internal value it wants to. You can likely reproduce the same behavior in VBS by using it's "Default" convention (I don't know what it is, I don't use VBS). However, even though it works in COM in a similar fashion to AutoIt, there is a translation that occurs before going to the COM object.
comment:4 by , on Nov 11, 2009 at 6:41:06 PM
Aha, I understand now - the Scripting.Dictionary COM object is responsible for how its methods define the "default" value for each parameter. So the value it assigns to the dictionary, as a result of calling its Add() method with "Default", is outside the control of AutoIt.
Thanks for taking the time to explain this, I appreciate it!

Um, okay. I'm not sure how you expect an AutoIt-specific keyword to be stored and preserved in an external object. This is certainly not a bug.