Commit b830c274 authored by dslomov@chromium.org's avatar dslomov@chromium.org

Handle property name "-0" correctly for typed arrays.

R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/670623003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24768 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 37b7dde5
......@@ -324,7 +324,8 @@ namespace internal {
V(value_string, "value") \
V(next_string, "next") \
V(byte_length_string, "byteLength") \
V(byte_offset_string, "byteOffset")
V(byte_offset_string, "byteOffset") \
V(minus_zero_string, "-0")
#define PRIVATE_SYMBOL_LIST(V) \
V(frozen_symbol) \
......
......@@ -316,6 +316,10 @@ bool LookupIterator::IsSpecialNumericIndex() const {
double d =
StringToDouble(isolate()->unicode_cache(), *name_string, NO_FLAGS);
if (!std::isnan(d)) {
if (String::Equals(isolate()->factory()->minus_zero_string(),
name_string))
return true;
Factory* factory = isolate()->factory();
Handle<Object> num = factory->NewNumber(d);
Handle<String> roundtrip_string = factory->NumberToString(num);
......
......@@ -500,6 +500,13 @@ function TestTypedArraysWithIllegalIndices() {
assertEquals(10, a["-1e2"]);
assertEquals(undefined, a[-1e2]);
a["-0"] = 256;
var s2 = " -0";
a[s2] = 255;
assertEquals(undefined, a["-0"]);
assertEquals(255, a[s2]);
assertEquals(0, a[-0]);
/* Chromium bug: 424619
* a[-Infinity] = 50;
* assertEquals(undefined, a[-Infinity]);
......@@ -542,6 +549,13 @@ function TestTypedArraysWithIllegalIndicesStrict() {
assertEquals(10, a["-1e2"]);
assertEquals(undefined, a[-1e2]);
a["-0"] = 256;
var s2 = " -0";
a[s2] = 255;
assertEquals(undefined, a["-0"]);
assertEquals(255, a[s2]);
assertEquals(0, a[-0]);
/* Chromium bug: 424619
* a[-Infinity] = 50;
* assertEquals(undefined, a[-Infinity]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment