Merge branch 'master' into plugins

This commit is contained in:
Stephen Chung 2020-08-23 17:54:02 +08:00
commit 4fff90d19b
2 changed files with 5 additions and 4 deletions

View File

@ -9,6 +9,7 @@ Bug fixes
* `Engine::compile_expression`, `Engine::eval_expression` etc. no longer parse anonymous functions and closures. * `Engine::compile_expression`, `Engine::eval_expression` etc. no longer parse anonymous functions and closures.
* Imported modules now work inside closures. * Imported modules now work inside closures.
* Closures that capture now work under `no_object`.
Version 0.18.2 Version 0.18.2

View File

@ -3167,6 +3167,8 @@ fn make_curry_from_externals(
let num_externals = externals.len(); let num_externals = externals.len();
let mut args: StaticVec<_> = Default::default(); let mut args: StaticVec<_> = Default::default();
args.push(fn_expr);
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]
externals.iter().for_each(|(var_name, pos)| { externals.iter().for_each(|(var_name, pos)| {
args.push(Expr::Variable(Box::new(( args.push(Expr::Variable(Box::new((
@ -3182,9 +3184,9 @@ fn make_curry_from_externals(
args.push(Expr::Variable(Box::new(((var_name, pos), None, 0, None)))); args.push(Expr::Variable(Box::new(((var_name, pos), None, 0, None))));
}); });
let hash = calc_fn_hash(empty(), KEYWORD_FN_PTR_CURRY, num_externals, empty()); let hash = calc_fn_hash(empty(), KEYWORD_FN_PTR_CURRY, num_externals + 1, empty());
let fn_call = Expr::FnCall(Box::new(( let expr = Expr::FnCall(Box::new((
(KEYWORD_FN_PTR_CURRY.into(), false, false, pos), (KEYWORD_FN_PTR_CURRY.into(), false, false, pos),
None, None,
hash, hash,
@ -3192,8 +3194,6 @@ fn make_curry_from_externals(
None, None,
))); )));
let expr = Expr::Dot(Box::new((fn_expr, fn_call, pos)));
// If there are captured variables, convert the entire expression into a statement block, // If there are captured variables, convert the entire expression into a statement block,
// then insert the relevant `Share` statements. // then insert the relevant `Share` statements.
#[cfg(not(feature = "no_closure"))] #[cfg(not(feature = "no_closure"))]