Closed Bug 57045 Opened 25 years ago Closed 25 years ago

negative integers as object properties: weird behavior

Categories

(Rhino Graveyard :: Core, defect, P3)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: david, Assigned: norrisboyd)

Details

When I use a negative integer as an object property name (is this even legal?) I get weird behavior with the latest rhinoTip. The following js shell session illustrates. Note that this does not occur with non-negative integers, or any floating-point values. Note that this is very similar to, but not quite the same behavior as that reported against spidermonkey in bug #57043 oxymoron:7 % java -jar rhinoTip/js.jar js> var o = new Object(); js> o[-1] = "number"; number js> o[-1] number js> o["-1"] js> o["-1"] = "string"; string js> o[-1] number js> o["-1"] string js> for(i in o) print(i + ": " + typeof i + ": " + o[i]); -1: number: number -1: string: string
Compare bug 57043 in JS Engine -
This seems to treat -1 and "-1" as distinct keys.
I have a fix for this. I'll run regression tests.
Status: NEW → ASSIGNED
Special processing of integers as strings wasn't handling negative integers.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Verified on Linux and WinNT via this testcase added to JS test suite: js/tests/js1_5/Regress/regress-57043.js
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.