Strict mode in functions check for static modules.

This commit is contained in:
Stephen Chung
2022-06-09 17:59:28 +08:00
parent 285bf23dfa
commit dcaac20eb9
5 changed files with 50 additions and 52 deletions

View File

@@ -91,18 +91,17 @@ fn test_options_strict_var() -> Result<(), Box<EvalAltResult>> {
#[cfg(not(feature = "no_function"))]
assert!(engine.compile("fn foo(x) { x + y }").is_err());
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_module"))]
{
assert!(engine.compile("print(h::y::z);").is_err());
engine.compile(r#"import "hello" as h; print(h::y::z);"#)?;
assert!(engine.compile("fn foo() { h::y::z }").is_err());
assert!(engine.compile("fn foo() { h::y::foo() }").is_err());
engine.compile(r#"import "hello" as h; fn foo() { h::a::b::c } print(h::y::z);"#)?;
assert!(engine.compile("let x = h::y::foo();").is_err());
engine.compile(r#"import "hello" as h; let x = h::y::foo();"#)?;
engine.compile(r#"import "hello" as h; fn foo() { h::a::b::c() } let x = h::y::foo();"#)?;
}
#[cfg(not(feature = "no_function"))]
#[cfg(not(feature = "no_module"))]
engine.compile("fn foo() { h::y::foo() }")?;
#[cfg(not(feature = "no_function"))]
{
assert!(engine.compile("let f = |y| x * y;").is_err());