v8/test/mjsunit/es7/regress/regress-5986.js
Caitlin Potter 6746227291 [builtins] fix incorrect return value in ArrayIncludes
Take runtime path if startIndex parameter requires a ToInteger() call,
which can modify the elements kind of the receiver.

This removes a stub call from the builtin, and simplifies code slightly.

BUG=v8:5986
R=bmeurer@chromium.org, cbruni@chromium.org

Change-Id: Id238a81ab8ba28621858004b34d00a4356b8037f
Reviewed-on: https://chromium-review.googlesource.com/445006
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Caitlin Potter <caitp@igalia.com>
Cr-Commit-Position: refs/heads/master@{#43323}
2017-02-20 14:41:25 +00:00

30 lines
841 B
JavaScript

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
var array = [1.7, 1.7, 1.7];
var mutator = {
[Symbol.toPrimitive]() {
Object.defineProperties(array, {
0: { get() { } },
1: { get() { } },
2: { get() { } },
});
return 0;
}
};
assertTrue(array.includes(undefined, mutator));
function search(array, searchElement, startIndex) {
return array.includes(searchElement, startIndex);
}
array = [1.7, 1.7, 1.7];
var not_mutator = { [Symbol.toPrimitive]() { return 0; } };
assertFalse(search(array, undefined, not_mutator));
assertFalse(search(array, undefined, not_mutator));
%OptimizeFunctionOnNextCall(search);
assertTrue(search(array, undefined, mutator));