Title: [260733] trunk
Revision
260733
Author
[email protected]
Date
2020-04-26 15:54:45 -0700 (Sun, 26 Apr 2020)

Log Message

Symbol should have [[Construct]] internal method
https://bugs.webkit.org/show_bug.cgi?id=211050

Reviewed by Yusuke Suzuki.

JSTests:

* stress/is-constructor.js:
* test262/expectations.yaml: Mark 2 test cases as passing.

Source/_javascript_Core:

This change introduces constructSymbol() method, which unconditionally throws
a TypeError, since its presence is observable when, for example, Symbol is a
[[ProxyTarget]] itself [1]. Aligns JSC with the spec [2], V8, and SpiderMonkey.

[1]: https://tc39.es/ecma262/#sec-proxycreate (step 7.b)
[2]: https://tc39.es/ecma262/#constructor

* runtime/SymbolConstructor.cpp:
(JSC::SymbolConstructor::SymbolConstructor):
(JSC::constructSymbol):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (260732 => 260733)


--- trunk/JSTests/ChangeLog	2020-04-26 21:30:38 UTC (rev 260732)
+++ trunk/JSTests/ChangeLog	2020-04-26 22:54:45 UTC (rev 260733)
@@ -1,5 +1,15 @@
 2020-04-26  Alexey Shvayka  <[email protected]>
 
+        Symbol should have [[Construct]] internal method
+        https://bugs.webkit.org/show_bug.cgi?id=211050
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/is-constructor.js:
+        * test262/expectations.yaml: Mark 2 test cases as passing.
+
+2020-04-26  Alexey Shvayka  <[email protected]>
+
         InternalFunction::createSubclassStructure should use newTarget's globalObject
         https://bugs.webkit.org/show_bug.cgi?id=202599
 

Modified: trunk/JSTests/stress/is-constructor.js (260732 => 260733)


--- trunk/JSTests/stress/is-constructor.js	2020-04-26 21:30:38 UTC (rev 260732)
+++ trunk/JSTests/stress/is-constructor.js	2020-04-26 22:54:45 UTC (rev 260733)
@@ -37,6 +37,7 @@
 assert(isConstructor(RegExp));
 assert(isConstructor(Set));
 assert(isConstructor(String));
+assert(isConstructor(Symbol));
 assert(isConstructor(WeakMap));
 assert(isConstructor(WeakSet));
 
@@ -65,9 +66,6 @@
 assert(!isConstructor(new Proxy({}, {})));
 assert(!isConstructor(Array.prototype));
 
-// Symbol is not a constructor.
-assert(!isConstructor(Symbol));
-
 // Getters / setters are not constructors.
 assert(!isConstructor(Object.getOwnPropertyDescriptor({get f(){}}, "f").get));
 assert(!isConstructor(Object.getOwnPropertyDescriptor({set f(x){}}, "f").set));
@@ -91,11 +89,12 @@
 assert(!isConstructor(Math.cos));
 assert(!isConstructor(JSON.stringify));
 assert(!isConstructor(Promise.all));
+assert(!isConstructor(Proxy.revocable));
 assert(!isConstructor(Symbol.for));
 assert(!isConstructor(Array.prototype.push));
 
 // Proxy and bound functions carry forward non-constructor-ness.
-assert(!isConstructor(new Proxy(Symbol, {})));
+assert(isConstructor(new Proxy(Symbol, {})));
+assert(isConstructor(Symbol.bind(null)));
 assert(!isConstructor(new Proxy(Math.cos, {})));
-assert(!isConstructor(Symbol.bind(null)));
 assert(!isConstructor(Math.cos.bind(null)));

Modified: trunk/JSTests/test262/expectations.yaml (260732 => 260733)


--- trunk/JSTests/test262/expectations.yaml	2020-04-26 21:30:38 UTC (rev 260732)
+++ trunk/JSTests/test262/expectations.yaml	2020-04-26 22:54:45 UTC (rev 260733)
@@ -1615,9 +1615,6 @@
 test/built-ins/String/prototype/replaceAll/searchValue-replacer-is-null.js:
   default: 'TypeError: null is not a function'
   strict mode: 'TypeError: null is not a function'
-test/built-ins/Symbol/is-constructor.js:
-  default: 'Test262Error: Expected true but got false'
-  strict mode: 'Test262Error: Expected true but got false'
 test/built-ins/ThrowTypeError/extensible.js:
   default: 'Test262Error: Expected SameValue(«true», «false») to be true'
   strict mode: 'Test262Error: Expected SameValue(«true», «false») to be true'

Modified: trunk/Source/_javascript_Core/ChangeLog (260732 => 260733)


--- trunk/Source/_javascript_Core/ChangeLog	2020-04-26 21:30:38 UTC (rev 260732)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-04-26 22:54:45 UTC (rev 260733)
@@ -1,5 +1,23 @@
 2020-04-26  Alexey Shvayka  <[email protected]>
 
+        Symbol should have [[Construct]] internal method
+        https://bugs.webkit.org/show_bug.cgi?id=211050
+
+        Reviewed by Yusuke Suzuki.
+
+        This change introduces constructSymbol() method, which unconditionally throws
+        a TypeError, since its presence is observable when, for example, Symbol is a
+        [[ProxyTarget]] itself [1]. Aligns JSC with the spec [2], V8, and SpiderMonkey.
+
+        [1]: https://tc39.es/ecma262/#sec-proxycreate (step 7.b)
+        [2]: https://tc39.es/ecma262/#constructor
+
+        * runtime/SymbolConstructor.cpp:
+        (JSC::SymbolConstructor::SymbolConstructor):
+        (JSC::constructSymbol):
+
+2020-04-26  Alexey Shvayka  <[email protected]>
+
         InternalFunction::createSubclassStructure should use newTarget's globalObject
         https://bugs.webkit.org/show_bug.cgi?id=202599
 

Modified: trunk/Source/_javascript_Core/runtime/SymbolConstructor.cpp (260732 => 260733)


--- trunk/Source/_javascript_Core/runtime/SymbolConstructor.cpp	2020-04-26 21:30:38 UTC (rev 260732)
+++ trunk/Source/_javascript_Core/runtime/SymbolConstructor.cpp	2020-04-26 22:54:45 UTC (rev 260733)
@@ -57,9 +57,10 @@
 */
 
 static EncodedJSValue JSC_HOST_CALL callSymbol(JSGlobalObject*, CallFrame*);
+static EncodedJSValue JSC_HOST_CALL constructSymbol(JSGlobalObject*, CallFrame*);
 
 SymbolConstructor::SymbolConstructor(VM& vm, Structure* structure)
-    : InternalFunction(vm, structure, callSymbol, nullptr)
+    : InternalFunction(vm, structure, callSymbol, constructSymbol)
 {
 }
 
@@ -91,6 +92,13 @@
     return JSValue::encode(Symbol::createWithDescription(vm, string));
 }
 
+static EncodedJSValue JSC_HOST_CALL constructSymbol(JSGlobalObject* globalObject, CallFrame* callFrame)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    return throwVMError(globalObject, scope, createNotAConstructorError(globalObject, callFrame->jsCallee()));
+}
+
 EncodedJSValue JSC_HOST_CALL symbolConstructorFor(JSGlobalObject* globalObject, CallFrame* callFrame)
 {
     VM& vm = globalObject->vm();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to