Commit 985a9dda authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

Fix "name" property of %ThrowTypeError% to be spec-conformant

This is a normative PR that reached consensus at the June 2019 TC39:
https://github.com/tc39/test262/pull/2299

Bug: v8:9646
Change-Id: Idbeea703fe264da43825729e7b37a08a1bb10001
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2360907
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69466}
parent 65dde243
......@@ -642,11 +642,14 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic() {
Handle<JSFunction> function = factory()->NewFunction(args);
function->shared().DontAdaptArguments();
// %ThrowTypeError% must not have a name property.
if (JSReceiver::DeleteProperty(function, factory()->name_string())
.IsNothing()) {
DCHECK(false);
}
// %ThrowTypeError% must have a name property with an empty string value. Per
// spec, ThrowTypeError's name is non-configurable, unlike ordinary functions'
// name property. To redefine it to be non-configurable, use
// SetOwnPropertyIgnoreAttributes.
JSObject::SetOwnPropertyIgnoreAttributes(
function, factory()->name_string(), factory()->empty_string(),
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY))
.Assert();
// length needs to be non configurable.
Handle<Object> value(Smi::FromInt(function->length()), isolate());
......
......@@ -5,8 +5,11 @@
var throwTypeErrorFunction =
Object.getOwnPropertyDescriptor(Function.prototype, 'arguments').get;
assertFalse(
Object.prototype.hasOwnProperty.call(throwTypeErrorFunction, 'name'));
var nameDesc =
Object.getOwnPropertyDescriptor(throwTypeErrorFunction, 'name');
assertFalse(nameDesc.configurable, 'configurable');
assertFalse(nameDesc.enumerable, 'enumerable');
assertFalse(nameDesc.writable, 'writable');
assertThrows(function() {
'use strict';
throwTypeErrorFunction.name = 'foo';
......
......@@ -502,9 +502,6 @@
'intl402/Intl/getCanonicalLocales/unicode-ext-canonicalize-yes-to-true': [FAIL],
'intl402/Intl/getCanonicalLocales/unicode-ext-key-with-digit': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=9646
'built-ins/ThrowTypeError/name': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=9742
'intl402/Locale/getters': [FAIL],
......
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