You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function f() int {
let f = 1
if f == 1 {
let a = f + 1 // vars from outer scopes are visible in inner scopes
check a == 2
}
// `a` should not be available here
return 0
}
The text was updated successfully, but these errors were encountered:
@chip-so This seems to be done? I couldn't find an explicit test for it, but the following passes:
let text = r#" function foo() int { let x = { let y = 4 : y } // This is an error - y does not exist in the outer scope return y}"#;let policy = parse_policy_str(text,Version::V1).expect("should parse");let r = Compiler::new(&policy).compile().unwrap_err().err_type;assert_eq!(r,CompileErrorType::NotDefined("Unknown identifier `y`".to_string()));
That works because you're using the block expression, which was implemented previously. Now it needs to work in all other contexts that have a block. This ticket is for adding it to if and match statements. We already implemented it for map, and if/match expressions are in different tickets.
Limit variable scope to its block.
c.f. Policy Lang v2 spec
The text was updated successfully, but these errors were encountered: