aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-08-03 14:25:26 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-09-01 09:45:56 +0200
commit6fa4d45b0d321d5d2c935ed000467b167d0c1b27 (patch)
treefef43524cf06c307cb0d5d5b9cba1254081f5a89 /tests
parentff8893d28d5d2e8470d04bf49af895f27bdc0343 (diff)
Parser: Preserve keywordiness of "static" across nested classes
"static" is a keyword in the context of JS classes, no matter how deeply nested. Therefore, keep track of the nesting level. Switching the keywordiness of "static" off during method definition parsing makes no sense as the standard doesn't mention such a thing. Method bodies are strict code where you cannot use "static" as identifier. Methods and properties can be called "static" no matter if static is a keyword or not. Fixes: QTBUG-96631 Change-Id: Ia09e52fe2ae72721fe1c8a9b95899a31095db988 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit b50d01891b1adba15c4cfc47ad078d227aa1f491)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 0c3a8d1703..71e3830fd2 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -260,6 +260,7 @@ private slots:
void urlObject();
void thisInConstructor();
void forOfAndGc();
+ void staticInNestedClasses();
public:
Q_INVOKABLE QJSValue throwingCppMethod1();
@@ -5571,6 +5572,22 @@ void tst_QJSEngine::forOfAndGc()
QTRY_VERIFY(o->property("count").toInt() > 32768);
}
+void tst_QJSEngine::staticInNestedClasses()
+{
+ QJSEngine engine;
+ const QString program = uR"(
+ class Tester {
+ constructor() {
+ new (class {})();
+ }
+ static get test() { return "a" }
+ }
+ Tester.test
+ )"_s;
+
+ QCOMPARE(engine.evaluate(program).toString(), u"a"_s);
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"