Closed Bug 418624 Opened 18 years ago Closed 18 years ago

Issues with vector used with number indexes

Categories

(Tamarin Graveyard :: Virtual Machine, defect, P1)

x86
Windows XP
defect

Tracking

(Not tracked)

VERIFIED FIXED
flash10

People

(Reporter: tierney, Assigned: tierney)

Details

Attachments

(2 files, 1 obsolete file)

Attached file Code showing the incorrect behavior. (obsolete) —
Getting/setting properties of a vector with string/number indexes should fail, but currently works. Attempts to set v["3"] or v[1.1] work, but shouldn't.
Add the bug file with the right content type
Attachment #304485 - Attachment is obsolete: true
Priority: -- → P1
Target Milestone: --- → flash10
bug is still present in vm, mark as defer?
Flags: flashplayer-review+
So, the vector proposal says: "NOTE If v is a Vector then reading and writing v[3.14] or v[-3] will always fail, though reading and writing v["3.14"] or v["-3"] will succeed. This behavior deviates from the 3rd Edition, where strings and numbers are interchangeable as property names. But that's no longer quite true in 4th Edition anyway, which has have namespaces and Name objects. Most attempts to set or get properties that are named by numbers that are not valid array indices are probably errors, especially if the object is an Array. Most attempts to read beyond the end of an Array are probably errors. And in a number of cases, attempts to write beyond the end of an Array are probably errors too. The Vector class makes it possible to discover these errors. " Implementing that won't be easy, as TC currently treats strings and numbers interchangably as property names. So, by the time we are looking up something in a Vector, we have no knowledge of whether the property name was originally a string or a number. So this would require some changes to generally property lookup, which I'm not sure we want to do at this point.
set milestone to future, deferring bug past fp10 release.
Flags: flashplayer-qrb?
Target Milestone: flash10 → Future
Jeff recommended making it an error to access v[3.14], or v["3.14"] - basically anything that looks like a number. We would be more restrictive than the ES4 proposal then, which would probably be better for future compatibility. This would also only affect the Vector property accessor code, rather than all property accessor code.
Target Milestone: Future → flash10
Also, looking at the code, the check for the error case would come after the common path taken where a uint index is provided. So this change would only incur the cost of an additional check when the property name is not a vector offset. Agree with Erik, the proposed solution is future proof and probably doesn't get in the way of any intended programs. (adding Lars in case he has a different opinion.) Jd
Flags: wanted-flashplayer10+
Flags: flashplayer-qrb?
Flags: flashplayer-qrb+
The easiest change is probably to make it an error to access any non-indexed properties. So accessing -1, 3.5, or "mystring" would produce an error.
Attempt to write a non-indexed dynamic property now always fails. Attempts to read a non-indexed dynamic property will check the prototype, and fail if the property does not exist in the prototype.
Attachment #335755 - Flags: review?(lhansen)
It is now an error to access any numeric property that is not an indexed property. If the property is non numeric, then it is looked up in the prototype.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Attachment #335755 - Flags: review?(lhansen) → review+
Flags: in-testsuite?
Flags: in-testsuite? → in-testsuite+
verified the fix. testcases are automated in test/acceptance/es4/nonindexproperty.as.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: