Optimize variable shadowing.

This commit is contained in:
Stephen Chung
2022-02-18 15:04:46 +08:00
parent 83786c992b
commit bb04fab011
10 changed files with 137 additions and 58 deletions

View File

@@ -25,11 +25,15 @@ fn test_options_allow() -> Result<(), Box<EvalAltResult>> {
assert!(engine.compile("let x = || 42;").is_err());
}
engine.compile("while x > y { foo(z); }")?;
let ast = engine.compile("let x = 0; while x < 10 { x += 1; }")?;
engine.set_allow_looping(false);
assert!(engine.compile("while x > y { foo(z); }").is_err());
engine.run_ast(&ast)?;
assert!(engine
.compile("let x = 0; while x < 10 { x += 1; }")
.is_err());
engine.compile("let x = 42; let x = 123;")?;