Title: [259216] trunk
- Revision
- 259216
- Author
- ticaiol...@gmail.com
- Date
- 2020-03-30 12:24:12 -0700 (Mon, 30 Mar 2020)
Log Message
[JSC] Public class field should accept "static" as field name
https://bugs.webkit.org/show_bug.cgi?id=209703
Reviewed by Ross Kirsling.
JSTests:
* stress/class-fields-with-special-names.js: Added.
Source/_javascript_Core:
It allows class fields being created using "static" as identifier
(https://tc39.es/ecma262/#prod-IdentifierName).
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseClass):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (259215 => 259216)
--- trunk/JSTests/ChangeLog 2020-03-30 19:23:05 UTC (rev 259215)
+++ trunk/JSTests/ChangeLog 2020-03-30 19:24:12 UTC (rev 259216)
@@ -1,3 +1,12 @@
+2020-03-30 Caio Lima <ticaiol...@gmail.com>
+
+ [JSC] Public class field should accept "static" as field name
+ https://bugs.webkit.org/show_bug.cgi?id=209703
+
+ Reviewed by Ross Kirsling.
+
+ * stress/class-fields-with-special-names.js: Added.
+
2020-03-28 Caio Lima <ticaiol...@gmail.com>
stress/test-out-of-memory.js test gaderning
Added: trunk/JSTests/stress/class-fields-with-special-names.js (0 => 259216)
--- trunk/JSTests/stress/class-fields-with-special-names.js (rev 0)
+++ trunk/JSTests/stress/class-fields-with-special-names.js 2020-03-30 19:24:12 UTC (rev 259216)
@@ -0,0 +1,45 @@
+//@ requireOptions("--usePublicClassFields=true")
+
+function assertEquals(e, a) {
+ if (a !== e)
+ throw new Error("Expected: " + e + " but got: " + a);
+}
+
+{
+ class A {
+ async
+ get
+ test() { return "foo"; }
+ }
+
+ let a = new A();
+ assertEquals(true, 'async' in a);
+ assertEquals("foo", a.test);
+}
+
+{
+ class A {
+ super;
+ static;
+ set;
+ get;
+ test() { return "foo"; }
+ }
+
+ let a = new A();
+ assertEquals(true, 'set' in a);
+ assertEquals(true, 'get' in a);
+ assertEquals(true, 'static' in a);
+ assertEquals(true, 'super' in a);
+ assertEquals("foo", a.test());
+}
+
+{
+ class A {
+ static = "test";
+ }
+
+ let a = new A();
+ assertEquals("test", a.static);
+}
+
Modified: trunk/Source/_javascript_Core/ChangeLog (259215 => 259216)
--- trunk/Source/_javascript_Core/ChangeLog 2020-03-30 19:23:05 UTC (rev 259215)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-03-30 19:24:12 UTC (rev 259216)
@@ -1,3 +1,16 @@
+2020-03-30 Caio Lima <ticaiol...@gmail.com>
+
+ [JSC] Public class field should accept "static" as field name
+ https://bugs.webkit.org/show_bug.cgi?id=209703
+
+ Reviewed by Ross Kirsling.
+
+ It allows class fields being created using "static" as identifier
+ (https://tc39.es/ecma262/#prod-IdentifierName).
+
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parseClass):
+
2020-03-28 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Use CacheableIdentifier for all ById case
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (259215 => 259216)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2020-03-30 19:23:05 UTC (rev 259215)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2020-03-30 19:24:12 UTC (rev 259216)
@@ -2876,8 +2876,8 @@
if (match(RESERVED_IF_STRICT) && *m_token.m_data.ident == m_vm.propertyNames->staticKeyword) {
SavePoint savePoint = createSavePoint(context);
next();
- if (match(OPENPAREN)) {
- // Reparse "static()" as a method named "static".
+ if (match(OPENPAREN) || match(SEMICOLON) || match(EQUAL)) {
+ // Reparse "static()" as a method or "static" as a class field.
restoreSavePoint(context, savePoint);
} else
tag = ClassElementTag::Static;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes