iterating through Dictionary keys does not maintain types

RESOLVED WONTFIX

Status

RESOLVED WONTFIX
9 years ago
a month ago

People

(Reporter: dschaffe, Unassigned)

Tracking

unspecified
Future
x86
Mac OS X
Bug Flags:
in-testsuite ?
flashplayer-qrb +
flashplayer-triage +

Details

(Reporter)

Description

9 years ago
A dictionary key "1234" is converted to Number when iterating with a "*" type.

Or is this a describeType finding the type of "*" data.

For example:
dict['1234']="value";
for (k:* in dict) {
    print ( "key type:" : describeType(k,FLASH10_FLAGS));
}

Full example:

dict_bug.as:
import flash.utils.*
import avmplus.*

var dictionary:Dictionary = new Dictionary();

var keyStringOfNumbers:String = "1234";
dictionary[keyStringOfNumbers] = "Value";

var keyStringOfLetters:String = "abcd";
dictionary[keyStringOfLetters] = "Value";

// "1234" is of type int
for (var keyStar:* in dictionary)
{
print("Key (*) '" + keyStar + "' is of type " + describeType(keyStar,FLASH10_FLAGS).@name);
}

// "1234" is of type String
for (var keyString:String in dictionary)
{
print("Key (String) '" + keyString + "' is of type " + describeType(keyString,FLASH10_FLAGS).@name);
}

$ asc -import builtin.abc dict_bug.as
$ avmshell dict_bug.abc
Key (*) 'abcd' is of type String
Key (*) '1234' is of type Number
Key (String) 'abcd' is of type String
Key (String) '1234' is of type String
Flags: in-testsuite?
Flags: flashplayer-triage+
Flags: flashplayer-qrb?
(Reporter)

Comment 1

9 years ago
moved from jira community issue: http://bugs.adobe.com/jira/browse/FP-1674

Updated

9 years ago
Flags: flashplayer-qrb? → flashplayer-qrb+
Priority: -- → P4
Target Milestone: --- → Future

Updated

9 years ago
Priority: P4 → --

Comment 2

9 years ago
It's not just iterating the keys. This is a serious bug. The documentation says that Dictionary uses strict equality (===) for key comparison, but this does not appear to be the case because Strings are converted.

        var d :Dictionary = new Dictionary();
        d["1"] = "string";
        d[1] = "int";
        trace("omg: " + d["1"]); // prints "omg: int"

Updated

9 years ago
Depends on: 535770
Status: NEW → RESOLVED
Last Resolved: a month ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.