diff --git a/RELEASES.md b/RELEASES.md index db26c661..7e9bb8b2 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -9,6 +9,7 @@ Bug fixes * `Engine::compile_expression`, `Engine::eval_expression` etc. no longer parse anonymous functions and closures. * Imported modules now work inside closures. +* Closures that capture now work under `no_object`. Version 0.18.2 diff --git a/src/parser.rs b/src/parser.rs index 01be7715..eaaf559d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3167,6 +3167,8 @@ fn make_curry_from_externals( let num_externals = externals.len(); let mut args: StaticVec<_> = Default::default(); + args.push(fn_expr); + #[cfg(not(feature = "no_closure"))] externals.iter().for_each(|(var_name, pos)| { 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)))); }); - 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), None, hash, @@ -3192,8 +3194,6 @@ fn make_curry_from_externals( 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, // then insert the relevant `Share` statements. #[cfg(not(feature = "no_closure"))]