about summary refs log tree commit diff stats
path: root/lib/quickjs
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-13 15:08:14 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-13 15:08:14 +0200
commit9ff482dd8d5b1b252e77712e9418b5b253f4bbf8 (patch)
tree874a56586491aa021d81f5d0cae4cdf401c57daa /lib/quickjs
parentb987408fb1086fdeca1fadfdbd5e7f68e1e23336 (diff)
downloadchawan-9ff482dd8d5b1b252e77712e9418b5b253f4bbf8.tar.gz
add_eval_variables: do not close over `this' twice
See https://github.com/bellard/quickjs/issues/192. (Thanks to @dchest
for the proposed fix.)
Diffstat (limited to 'lib/quickjs')
-rw-r--r--lib/quickjs/quickjs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/quickjs/quickjs.c b/lib/quickjs/quickjs.c
index 197887b0..61bcce93 100644
--- a/lib/quickjs/quickjs.c
+++ b/lib/quickjs/quickjs.c
@@ -30469,7 +30469,8 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
                 /* do not close top level last result */
                 if (vd->scope_level == 0 &&
                     vd->var_name != JS_ATOM__ret_ &&
-                    vd->var_name != JS_ATOM_NULL) {
+                    vd->var_name != JS_ATOM_NULL &&
+                    (!has_this_binding || vd->var_name != JS_ATOM_this)) {
                     get_closure_var(ctx, s, fd,
                                     FALSE, i, vd->var_name, FALSE, FALSE,
                                     JS_VAR_NORMAL);