summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2023-12-22 11:04:22 +0100
committerFabrice Bellard <fabrice@bellard.org>2023-12-22 11:04:22 +0100
commit3ba181e6c6d659e85fd6a296c00eea7d29637112 (patch)
tree247c0aea33c6ff6b7a97a9109ce8776e008c5de4 /quickjs.c
parentc3599515c87faea1bab5a0c95a93f45090ea2561 (diff)
downloadquickjs-3ba181e6c6d659e85fd6a296c00eea7d29637112.tar.gz
quickjs-3ba181e6c6d659e85fd6a296c00eea7d29637112.zip
fixed define own property with writable=false on module namespace
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/quickjs.c b/quickjs.c
index 45b0be8..43dbe34 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -9081,15 +9081,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);