[gjs/ewlsh/enable-static-blocks] global: Enable static class blocks




commit f95c8a8876894d6bf79aefcda57f6763217fd63f
Author: Evan Welsh <contact evanwelsh com>
Date:   Sun Jan 30 16:02:02 2022 -0800

    global: Enable static class blocks

 gjs/engine.cpp                 |  1 +
 installed-tests/js/testself.js | 10 ++++++++++
 2 files changed, 11 insertions(+)
---
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index 1da606b8d..1738f67c8 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -170,6 +170,7 @@ JSContext* gjs_create_js_context(GjsContextPrivate* uninitialized_gjs) {
     JS::ContextOptionsRef(cx)
         .setAsmJS(enable_jit)
         .setTopLevelAwait(false)
+        .setClassStaticBlocks(true)
         .setPrivateClassFields(true)
         .setPrivateClassMethods(true);
 
diff --git a/installed-tests/js/testself.js b/installed-tests/js/testself.js
index 85332e75c..6d342bfe5 100644
--- a/installed-tests/js/testself.js
+++ b/installed-tests/js/testself.js
@@ -54,4 +54,14 @@ describe('SpiderMonkey features check', function () {
     it('Intl API was compiled into SpiderMonkey', function () {
         expect(Intl).toBeDefined();
     });
+
+    it('class static blocks are enabled', function () {
+        class Test {
+            static {
+                Test.x = 4;
+            }
+        }
+
+        expect(Test.x).toBe(4);
+    });
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]