Use actual outer scope for function-bang calls.

This commit is contained in:
Stephen Chung
2021-11-14 22:48:57 +08:00
parent dc918447b6
commit 615c3acad6
7 changed files with 67 additions and 19 deletions

View File

@@ -164,5 +164,22 @@ fn test_functions_bang() -> Result<(), Box<EvalAltResult>> {
165
);
assert_eq!(
engine.eval::<INT>(
"
fn foo() {
hello = 0;
hello + bar
}
let hello = 42;
let bar = 123;
foo!()
",
)?,
123
);
Ok(())
}

View File

@@ -204,8 +204,7 @@ fn test_function_pointers() -> Result<(), Box<EvalAltResult>> {
}
#[test]
#[cfg(not(feature = "no_closure"))]
fn test_internal_fn_captures() -> Result<(), Box<EvalAltResult>> {
fn test_internal_fn_bang() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(
@@ -219,7 +218,7 @@ fn test_internal_fn_captures() -> Result<(), Box<EvalAltResult>> {
foo!(1) + x
"
)?,
83
84
);
assert!(engine