Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finicky local environment handling #2

Open
wiseodd opened this issue Jul 7, 2024 · 0 comments
Open

Finicky local environment handling #2

wiseodd opened this issue Jul 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@wiseodd
Copy link
Owner

wiseodd commented Jul 7, 2024

Something is not right around here:

rustlox/src/interpreter.rs

Lines 159 to 184 in f7a1899

Stmt::Block { statements } => self.execute_block(
statements,
Rc::new(RefCell::new(Environment::new(Some(
self.environment.clone(),
)))),
),
_ => unreachable!(),
}
}
pub fn execute_block(
&mut self,
statements: &Vec<Option<Box<Stmt>>>,
environment: Rc<RefCell<Environment>>,
) -> Result<(), LoxError> {
let previous = self.environment.clone();
self.environment = environment.clone();
for stmt in statements.to_owned().iter().flatten() {
self.execute(stmt)?;
}
self.environment = previous;
Ok(())
}

@wiseodd wiseodd added the bug Something isn't working label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant