Closed Bug 507627 Opened 15 years ago Closed 6 years ago

iterating through Dictionary keys does not maintain types

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX
Future

People

(Reporter: dschaffe, Unassigned)

References

Details

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?
moved from jira community issue: http://bugs.adobe.com/jira/browse/FP-1674
Flags: flashplayer-qrb? → flashplayer-qrb+
Priority: -- → P4
Target Milestone: --- → Future
Priority: P4 → --
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"
Depends on: 535770
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.