about summary refs log tree commit diff stats
path: root/lib/quickjs/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2023-12-22 11:04:22 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-22 15:05:54 +0100
commitcbd3e7c49001d15ea17aecb869af830bfd2cadcc (patch)
tree2e74fbc27c46b9ce714e2225c8456000d896520c /lib/quickjs/quickjs.c
parent140995dcac79e7fafaae52f56a31cdf7f7074fde (diff)
downloadchawan-cbd3e7c49001d15ea17aecb869af830bfd2cadcc.tar.gz
fixed define own property with writable=false on module namespace
Diffstat (limited to 'lib/quickjs/quickjs.c')
-rw-r--r--lib/quickjs/quickjs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index a9e89211..fb965382 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -9201,15 +9201,19 @@ int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
                                spaces. */
                             if (!js_same_value(ctx, val, *pr->u.var_ref->pvalue))
                                 goto not_configurable;
+                        } else {
+                            /* update the reference */
+                            set_value(ctx, pr->u.var_ref->pvalue,
+                                      JS_DupValue(ctx, val));
                         }
-                        /* update the reference */
-                        set_value(ctx, pr->u.var_ref->pvalue,
-                                  JS_DupValue(ctx, val));
                     }
                     /* if writable is set to false, no longer a
                        reference (for mapped arguments) */
                     if ((flags & (JS_PROP_HAS_WRITABLE | JS_PROP_WRITABLE)) == JS_PROP_HAS_WRITABLE) {
                         JSValue val1;
+                        if (p->class_id == JS_CLASS_MODULE_NS) {
+                            return JS_ThrowTypeErrorOrFalse(ctx, flags, "module namespace properties have writable = false");
+                        }
                         if (js_shape_prepare_update(ctx, p, &prs))
                             return -1;
                         val1 = JS_DupValue(ctx, *pr->u.var_ref->pvalue);