mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 13:48:11 +08:00
fixed lexical scope of 'this' with eval (github issue #192)
This commit is contained in:
parent
26fdf659e3
commit
c4cdd61a3e
13
quickjs.c
13
quickjs.c
@ -29993,12 +29993,13 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
|
|||||||
is_arg_scope = (scope_idx == ARG_SCOPE_END);
|
is_arg_scope = (scope_idx == ARG_SCOPE_END);
|
||||||
if (!is_arg_scope) {
|
if (!is_arg_scope) {
|
||||||
/* add unscoped variables */
|
/* add unscoped variables */
|
||||||
|
/* XXX: propagate is_const and var_kind too ? */
|
||||||
for(i = 0; i < fd->arg_count; i++) {
|
for(i = 0; i < fd->arg_count; i++) {
|
||||||
vd = &fd->args[i];
|
vd = &fd->args[i];
|
||||||
if (vd->var_name != JS_ATOM_NULL) {
|
if (vd->var_name != JS_ATOM_NULL) {
|
||||||
get_closure_var(ctx, s, fd,
|
get_closure_var(ctx, s, fd,
|
||||||
TRUE, i, vd->var_name, FALSE, FALSE,
|
TRUE, i, vd->var_name, FALSE,
|
||||||
JS_VAR_NORMAL);
|
vd->is_lexical, JS_VAR_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i = 0; i < fd->var_count; i++) {
|
for(i = 0; i < fd->var_count; i++) {
|
||||||
@ -30008,8 +30009,8 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
|
|||||||
vd->var_name != JS_ATOM__ret_ &&
|
vd->var_name != JS_ATOM__ret_ &&
|
||||||
vd->var_name != JS_ATOM_NULL) {
|
vd->var_name != JS_ATOM_NULL) {
|
||||||
get_closure_var(ctx, s, fd,
|
get_closure_var(ctx, s, fd,
|
||||||
FALSE, i, vd->var_name, FALSE, FALSE,
|
FALSE, i, vd->var_name, FALSE,
|
||||||
JS_VAR_NORMAL);
|
vd->is_lexical, JS_VAR_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -30018,8 +30019,8 @@ static void add_eval_variables(JSContext *ctx, JSFunctionDef *s)
|
|||||||
/* do not close top level last result */
|
/* do not close top level last result */
|
||||||
if (vd->scope_level == 0 && is_var_in_arg_scope(vd)) {
|
if (vd->scope_level == 0 && is_var_in_arg_scope(vd)) {
|
||||||
get_closure_var(ctx, s, fd,
|
get_closure_var(ctx, s, fd,
|
||||||
FALSE, i, vd->var_name, FALSE, FALSE,
|
FALSE, i, vd->var_name, FALSE,
|
||||||
JS_VAR_NORMAL);
|
vd->is_lexical, JS_VAR_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user