Commit cf7646c5 authored by Gus Caplan's avatar Gus Caplan Committed by Commit Bot

Remove own toString from NativeError prototype

In 5742da05, the toString property was
accidentally applied to all NativeError prototypes, when it should only
be inherited from Error.prototype.

Refs: https://github.com/tc39/ecma262/issues/1794
Bug: v8:10017
Change-Id: I2af9a31f463deb9871dd7a4a5a2e4dd7485ed38c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1933054Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65355}
parent 33eb4730
...@@ -1366,11 +1366,6 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global, ...@@ -1366,11 +1366,6 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
isolate->native_context()->set_error_to_string(*to_string_fun); isolate->native_context()->set_error_to_string(*to_string_fun);
isolate->native_context()->set_initial_error_prototype(*prototype); isolate->native_context()->set_initial_error_prototype(*prototype);
} else { } else {
DCHECK(isolate->native_context()->error_to_string().IsJSFunction());
JSObject::AddProperty(isolate, prototype, factory->toString_string(),
isolate->error_to_string(), DONT_ENUM);
Handle<JSFunction> global_error = isolate->error_function(); Handle<JSFunction> global_error = isolate->error_function();
CHECK(JSReceiver::SetPrototype(error_fun, global_error, false, CHECK(JSReceiver::SetPrototype(error_fun, global_error, false,
kThrowOnError) kThrowOnError)
......
// Copyright 2019 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.
[
EvalError, RangeError, ReferenceError,
SyntaxError, TypeError, URIError,
].forEach((NativeError) => {
assertFalse(NativeError.prototype.hasOwnProperty('toString'));
assertEquals(NativeError.prototype.toString, Error.prototype.toString);
});
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