Diff
Modified: trunk/JSTests/ChangeLog (215688 => 215689)
--- trunk/JSTests/ChangeLog 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/JSTests/ChangeLog 2017-04-24 19:25:01 UTC (rev 215689)
@@ -1,5 +1,14 @@
2017-04-24 Joseph Pecoraro <pecor...@apple.com>
+ test262: test262/test/language/computed-property-names/class/static/getter-prototype.js
+ https://bugs.webkit.org/show_bug.cgi?id=170897
+
+ Reviewed by Saam Barati.
+
+ * test262.yaml:
+
+2017-04-24 Joseph Pecoraro <pecor...@apple.com>
+
Address some FIXMEs in _javascript_ tests for bugs that have been fixed
https://bugs.webkit.org/show_bug.cgi?id=171191
Modified: trunk/JSTests/test262.yaml (215688 => 215689)
--- trunk/JSTests/test262.yaml 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/JSTests/test262.yaml 2017-04-24 19:25:01 UTC (rev 215689)
@@ -52194,9 +52194,9 @@
- path: test262/test/language/computed-property-names/class/static/getter-constructor.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/computed-property-names/class/static/getter-prototype.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
- path: test262/test/language/computed-property-names/class/static/getter-prototype.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/computed-property-names/class/static/method-constructor.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
- path: test262/test/language/computed-property-names/class/static/method-constructor.js
@@ -52222,9 +52222,9 @@
- path: test262/test/language/computed-property-names/class/static/setter-constructor.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/computed-property-names/class/static/setter-prototype.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
- path: test262/test/language/computed-property-names/class/static/setter-prototype.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/computed-property-names/object/accessor/getter-duplicates.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
- path: test262/test/language/computed-property-names/object/accessor/getter-duplicates.js
@@ -73154,9 +73154,9 @@
- path: test262/test/language/statements/class/definition/fn-name-static-precedence.js
cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], [:strict]
- path: test262/test/language/statements/class/definition/getters-non-configurable-err.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
- path: test262/test/language/statements/class/definition/getters-non-configurable-err.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/statements/class/definition/getters-prop-desc.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
- path: test262/test/language/statements/class/definition/getters-prop-desc.js
@@ -73306,9 +73306,9 @@
- path: test262/test/language/statements/class/definition/prototype-wiring.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/statements/class/definition/setters-non-configurable-err.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], []
- path: test262/test/language/statements/class/definition/setters-non-configurable-err.js
- cmd: runTest262 :fail, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
+ cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js"], [:strict]
- path: test262/test/language/statements/class/definition/setters-prop-desc.js
cmd: runTest262 :normal, "NoException", ["../../../../../harness/assert.js", "../../../../../harness/sta.js", "../../../../../harness/propertyHelper.js"], []
- path: test262/test/language/statements/class/definition/setters-prop-desc.js
Modified: trunk/LayoutTests/ChangeLog (215688 => 215689)
--- trunk/LayoutTests/ChangeLog 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/LayoutTests/ChangeLog 2017-04-24 19:25:01 UTC (rev 215689)
@@ -1,5 +1,16 @@
2017-04-24 Joseph Pecoraro <pecor...@apple.com>
+ test262: test262/test/language/computed-property-names/class/static/getter-prototype.js
+ https://bugs.webkit.org/show_bug.cgi?id=170897
+
+ Reviewed by Saam Barati.
+
+ * js/class-syntax-declaration-expected.txt:
+ * js/script-tests/class-syntax-declaration.js:
+ Extend tests for static and non-static methods named "constructor" and "prototype".
+
+2017-04-24 Joseph Pecoraro <pecor...@apple.com>
+
Address some FIXMEs in _javascript_ tests for bugs that have been fixed
https://bugs.webkit.org/show_bug.cgi?id=171191
Modified: trunk/LayoutTests/js/class-syntax-declaration-expected.txt (215688 => 215689)
--- trunk/LayoutTests/js/class-syntax-declaration-expected.txt 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/LayoutTests/js/class-syntax-declaration-expected.txt 2017-04-24 19:25:01 UTC (rev 215689)
@@ -24,12 +24,20 @@
PASS class X { constructor() {} constructor() {} }:::SyntaxError: Cannot declare multiple constructors in a single class.
PASS class X { get constructor() {} }:::SyntaxError: Cannot declare a getter or setter named 'constructor'.
PASS class X { set constructor() {} }:::SyntaxError: Cannot declare a getter or setter named 'constructor'.
+PASS class X { ['constructor']() {} }
+PASS class X { ['constructor']() { throw 'unreached' } }; new X
PASS class X { constructor() {} static constructor() { return staticMethodValue; } }
PASS class X { constructor() {} static constructor() { return staticMethodValue; } }; X.constructor():::staticMethodValue
+PASS class X { constructor() {} static get constructor() { return staticMethodValue; } }
+PASS class X { constructor() {} static get constructor() { return staticMethodValue; } }; X.constructor:::staticMethodValue
PASS class X { constructor() {} static prototype() {} }:::SyntaxError: Cannot declare a static method named 'prototype'.
PASS class X { constructor() {} static get prototype() {} }:::SyntaxError: Cannot declare a static method named 'prototype'.
PASS class X { constructor() {} static set prototype() {} }:::SyntaxError: Cannot declare a static method named 'prototype'.
+PASS class X { constructor() {} static get ['prototype']() {} }:::TypeError: Attempting to change configurable attribute of unconfigurable property.
+PASS class X { constructor() {} static set ['prototype'](x) {} }:::TypeError: Attempting to change configurable attribute of unconfigurable property.
PASS class X { constructor() {} prototype() { return instanceMethodValue; } }
+PASS class X { constructor() {} get prototype() { return instanceMethodValue; } }
+PASS class X { constructor() {} set prototype(x) { } }
PASS class X { constructor() {} prototype() { return instanceMethodValue; } }; (new X).prototype():::instanceMethodValue
PASS class X { constructor() {} set foo(a) {} }
PASS class X { constructor() {} set foo({x, y}) {} }
Modified: trunk/LayoutTests/js/script-tests/class-syntax-declaration.js (215688 => 215689)
--- trunk/LayoutTests/js/script-tests/class-syntax-declaration.js 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/LayoutTests/js/script-tests/class-syntax-declaration.js 2017-04-24 19:25:01 UTC (rev 215689)
@@ -74,13 +74,21 @@
shouldThrow("class X { constructor() {} constructor() {} }", "'SyntaxError: Cannot declare multiple constructors in a single class.'");
shouldThrow("class X { get constructor() {} }", "'SyntaxError: Cannot declare a getter or setter named \\'constructor\\'.'");
shouldThrow("class X { set constructor() {} }", "'SyntaxError: Cannot declare a getter or setter named \\'constructor\\'.'");
+shouldNotThrow("class X { ['constructor']() {} }");
+shouldNotThrow("class X { ['constructor']() { throw 'unreached' } }; new X");
shouldNotThrow("class X { constructor() {} static constructor() { return staticMethodValue; } }");
shouldBe("class X { constructor() {} static constructor() { return staticMethodValue; } }; X.constructor()", "staticMethodValue");
+shouldNotThrow("class X { constructor() {} static get constructor() { return staticMethodValue; } }");
+shouldBe("class X { constructor() {} static get constructor() { return staticMethodValue; } }; X.constructor", "staticMethodValue");
shouldThrow("class X { constructor() {} static prototype() {} }", "'SyntaxError: Cannot declare a static method named \\'prototype\\'.'");
shouldThrow("class X { constructor() {} static get prototype() {} }", "'SyntaxError: Cannot declare a static method named \\'prototype\\'.'");
shouldThrow("class X { constructor() {} static set prototype() {} }", "'SyntaxError: Cannot declare a static method named \\'prototype\\'.'");
+shouldThrow("class X { constructor() {} static get ['prototype']() {} }", "'TypeError: Attempting to change configurable attribute of unconfigurable property.'");
+shouldThrow("class X { constructor() {} static set ['prototype'](x) {} }", "'TypeError: Attempting to change configurable attribute of unconfigurable property.'");
shouldNotThrow("class X { constructor() {} prototype() { return instanceMethodValue; } }");
+shouldNotThrow("class X { constructor() {} get prototype() { return instanceMethodValue; } }");
+shouldNotThrow("class X { constructor() {} set prototype(x) { } }");
shouldBe("class X { constructor() {} prototype() { return instanceMethodValue; } }; (new X).prototype()", "instanceMethodValue");
shouldNotThrow("class X { constructor() {} set foo(a) {} }");
Modified: trunk/Source/_javascript_Core/ChangeLog (215688 => 215689)
--- trunk/Source/_javascript_Core/ChangeLog 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-04-24 19:25:01 UTC (rev 215689)
@@ -1,5 +1,32 @@
2017-04-24 Joseph Pecoraro <pecor...@apple.com>
+ test262: test262/test/language/computed-property-names/class/static/getter-prototype.js
+ https://bugs.webkit.org/show_bug.cgi?id=170897
+
+ Reviewed by Saam Barati.
+
+ * parser/ASTBuilder.h:
+ (JSC::ASTBuilder::createArguments):
+ (JSC::ASTBuilder::createArgumentsList):
+ Reorder so all the createProperty methods are grouped together.
+
+ * parser/Parser.h:
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parseClass):
+ (JSC::Parser<LexerType>::parseProperty):
+ (JSC::Parser<LexerType>::parseGetterSetter):
+ Refine the conditions for syntax errors for getter/setter
+ properties names. "prototype" is not allowed as a static
+ and "constructor" is not all when non-static.
+
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::putGetter):
+ (JSC::JSObject::putSetter):
+ Throw exceptions. These methods are only used by this path
+ via op_put_getter_by_val / op_put_setter_by_val.
+
+2017-04-24 Joseph Pecoraro <pecor...@apple.com>
+
test262: test262/test/language/statements/for-of/dstr-array-elem-init-fn-name-arrow.js
https://bugs.webkit.org/show_bug.cgi?id=171160
Modified: trunk/Source/_javascript_Core/parser/ASTBuilder.h (215688 => 215689)
--- trunk/Source/_javascript_Core/parser/ASTBuilder.h 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/Source/_javascript_Core/parser/ASTBuilder.h 2017-04-24 19:25:01 UTC (rev 215689)
@@ -453,6 +453,11 @@
return result;
}
+ ArgumentsNode* createArguments() { return new (m_parserArena) ArgumentsNode(); }
+ ArgumentsNode* createArguments(ArgumentListNode* args) { return new (m_parserArena) ArgumentsNode(args); }
+ ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, arg); }
+ ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ArgumentListNode* args, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, args, arg); }
+
NEVER_INLINE PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, bool,
const Identifier* name, const ParserFunctionInfo<ASTBuilder>& functionInfo, bool isClassProperty)
{
@@ -485,11 +490,6 @@
return new (m_parserArena) PropertyNode(ident, methodDef, type, PropertyNode::Unknown, SuperBinding::Needed, isClassProperty);
}
- ArgumentsNode* createArguments() { return new (m_parserArena) ArgumentsNode(); }
- ArgumentsNode* createArguments(ArgumentListNode* args) { return new (m_parserArena) ArgumentsNode(args); }
- ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, arg); }
- ArgumentListNode* createArgumentsList(const JSTokenLocation& location, ArgumentListNode* args, ExpressionNode* arg) { return new (m_parserArena) ArgumentListNode(location, args, arg); }
-
PropertyNode* createProperty(const Identifier* propertyName, ExpressionNode* node, PropertyNode::Type type, PropertyNode::PutType putType, bool, SuperBinding superBinding, InferName inferName, bool isClassProperty)
{
if (inferName == InferName::Allowed) {
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (215688 => 215689)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2017-04-24 19:25:01 UTC (rev 215689)
@@ -2685,8 +2685,8 @@
const bool alwaysStrictInsideClass = true;
if (isGetter || isSetter) {
bool isClassProperty = true;
- property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter, methodStart,
- ConstructorKind::None, isClassProperty);
+ property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter,
+ methodStart, ConstructorKind::None, isClassProperty, isStaticMethod);
failIfFalse(property, "Cannot parse this method");
} else {
ParserFunctionInfo<TreeBuilder> methodInfo;
@@ -2721,8 +2721,10 @@
if (computedPropertyName) {
property = context.createProperty(computedPropertyName, method, static_cast<PropertyNode::Type>(PropertyNode::Constant | PropertyNode::Computed),
PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, isClassProperty);
- } else
- property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, InferName::Allowed, isClassProperty);
+ } else {
+ property = context.createProperty(methodInfo.name, method, PropertyNode::Constant,
+ PropertyNode::Unknown, alwaysStrictInsideClass, SuperBinding::Needed, InferName::Allowed, isClassProperty);
+ }
}
TreePropertyList& tail = isStaticMethod ? staticMethodsTail : instanceMethodsTail;
@@ -3688,6 +3690,7 @@
bool isAsync = false;
bool isGenerator = false;
bool isClassProperty = false;
+ bool isStaticMethod = false;
bool isAsyncMethod = false;
if (consume(TIMES))
isGenerator = true;
@@ -3756,7 +3759,7 @@
goto parseProperty;
} else
failWithMessage("Expected a ':' following the property name '", ident->impl(), "'");
- return parseGetterSetter(context, complete, type, getterOrSetterStartOffset, ConstructorKind::None, isClassProperty);
+ return parseGetterSetter(context, complete, type, getterOrSetterStartOffset, ConstructorKind::None, isClassProperty, isStaticMethod);
}
case DOUBLE:
case INTEGER: {
@@ -3827,7 +3830,7 @@
template <typename LexerType>
template <class TreeBuilder> TreeProperty Parser<LexerType>::parseGetterSetter(TreeBuilder& context, bool strict, PropertyNode::Type type, unsigned getterOrSetterStartOffset,
- ConstructorKind constructorKind, bool isClassProperty)
+ ConstructorKind constructorKind, bool isClassProperty, bool isStaticMethod)
{
const Identifier* stringPropertyName = 0;
double numericPropertyName = 0;
@@ -3837,9 +3840,9 @@
if (matchSpecIdentifier() || match(STRING) || m_token.m_type & KeywordTokenFlag) {
stringPropertyName = m_token.m_data.ident;
- semanticFailIfTrue(isClassProperty && *stringPropertyName == m_vm->propertyNames->prototype,
+ semanticFailIfTrue(isClassProperty && isStaticMethod && *stringPropertyName == m_vm->propertyNames->prototype,
"Cannot declare a static method named 'prototype'");
- semanticFailIfTrue(isClassProperty && *stringPropertyName == m_vm->propertyNames->constructor,
+ semanticFailIfTrue(isClassProperty && !isStaticMethod && *stringPropertyName == m_vm->propertyNames->constructor,
"Cannot declare a getter or setter named 'constructor'");
next();
} else if (match(DOUBLE) || match(INTEGER)) {
Modified: trunk/Source/_javascript_Core/parser/Parser.h (215688 => 215689)
--- trunk/Source/_javascript_Core/parser/Parser.h 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/Source/_javascript_Core/parser/Parser.h 2017-04-24 19:25:01 UTC (rev 215689)
@@ -1579,7 +1579,7 @@
template <class TreeBuilder> ALWAYS_INLINE TreeExpression parseArgument(TreeBuilder&, ArgumentType&);
template <class TreeBuilder> TreeProperty parseProperty(TreeBuilder&, bool strict);
template <class TreeBuilder> TreeExpression parsePropertyMethod(TreeBuilder& context, const Identifier* methodName, bool isGenerator, bool isAsyncMethod);
- template <class TreeBuilder> TreeProperty parseGetterSetter(TreeBuilder&, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind, bool isClassProperty);
+ template <class TreeBuilder> TreeProperty parseGetterSetter(TreeBuilder&, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind, bool isClassProperty, bool isStaticMethod);
template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&, SyntaxChecker&, const JSTokenLocation&, int, int functionKeywordStart, int functionNameStart, int parametersStart, ConstructorKind, SuperBinding, FunctionBodyType, unsigned, SourceParseMode);
template <class TreeBuilder> ALWAYS_INLINE bool parseFormalParameters(TreeBuilder&, TreeFormalParameterList, bool isArrowFunction, unsigned&);
enum VarDeclarationListContext { ForLoopContext, VarDeclarationContext };
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (215688 => 215689)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2017-04-24 18:08:56 UTC (rev 215688)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2017-04-24 19:25:01 UTC (rev 215689)
@@ -1707,7 +1707,7 @@
if (!(attributes & DontEnum))
descriptor.setEnumerable(true);
- return defineOwnProperty(this, exec, propertyName, descriptor, false);
+ return defineOwnProperty(this, exec, propertyName, descriptor, true);
}
bool JSObject::putSetter(ExecState* exec, PropertyName propertyName, JSValue setter, unsigned attributes)
@@ -1721,7 +1721,7 @@
if (!(attributes & DontEnum))
descriptor.setEnumerable(true);
- return defineOwnProperty(this, exec, propertyName, descriptor, false);
+ return defineOwnProperty(this, exec, propertyName, descriptor, true);
}
bool JSObject::putDirectAccessor(ExecState* exec, PropertyName propertyName, JSValue value, unsigned attributes)