Skip to content

Commit c4cdd61

Browse files
author
Fabrice Bellard
committed
fixed lexical scope of 'this' with eval (github issue #192)
1 parent 26fdf65 commit c4cdd61

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Diff for: quickjs.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -29993,12 +29993,13 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
2999329993
is_arg_scope = (scope_idx == ARG_SCOPE_END);
2999429994
if (!is_arg_scope) {
2999529995
/* add unscoped variables */
29996+
/* XXX: propagate is_const and var_kind too ? */
2999629997
for(i = 0; i < fd->arg_count; i++) {
2999729998
vd = &fd->args[i];
2999829999
if (vd->var_name != JS_ATOM_NULL) {
2999930000
get_closure_var(ctx, s, fd,
30000-
TRUE, i, vd->var_name, FALSE, FALSE,
30001-
JS_VAR_NORMAL);
30001+
TRUE, i, vd->var_name, FALSE,
30002+
vd->is_lexical, JS_VAR_NORMAL);
3000230003
}
3000330004
}
3000430005
for(i = 0; i < fd->var_count; i++) {
@@ -30008,8 +30009,8 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
3000830009
vd->var_name != JS_ATOM__ret_ &&
3000930010
vd->var_name != JS_ATOM_NULL) {
3001030011
get_closure_var(ctx, s, fd,
30011-
FALSE, i, vd->var_name, FALSE, FALSE,
30012-
JS_VAR_NORMAL);
30012+
FALSE, i, vd->var_name, FALSE,
30013+
vd->is_lexical, JS_VAR_NORMAL);
3001330014
}
3001430015
}
3001530016
} else {
@@ -30018,8 +30019,8 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
3001830019
/* do not close top level last result */
3001930020
if (vd->scope_level == 0 && is_var_in_arg_scope(vd)) {
3002030021
get_closure_var(ctx, s, fd,
30021-
FALSE, i, vd->var_name, FALSE, FALSE,
30022-
JS_VAR_NORMAL);
30022+
FALSE, i, vd->var_name, FALSE,
30023+
vd->is_lexical, JS_VAR_NORMAL);
3002330024
}
3002430025
}
3002530026
}

0 commit comments

Comments
 (0)