Fix encapsulated environment in module functions.

This commit is contained in:
Stephen Chung
2022-01-30 17:27:13 +08:00
parent 8fc80ecd10
commit 7b92a80c32
13 changed files with 150 additions and 63 deletions

View File

@@ -646,13 +646,12 @@ impl Engine {
};
mem::swap(&mut global.source, &mut source);
let level = _level + 1;
let result = if _is_method_call {
// Method call of script function - map first argument to `this`
let (first_arg, rest_args) = args.split_first_mut().unwrap();
let level = _level + 1;
let result = self.call_script_fn(
scope,
global,
@@ -679,8 +678,6 @@ impl Engine {
.change_first_arg_to_copy(args);
}
let level = _level + 1;
let result = self.call_script_fn(
scope, global, state, lib, &mut None, func, args, pos, true, level,
);