panicked at 'assertion failed: old_local.is_none()'
charlesxsh opened this issue · comments
For given input file:
The following code:
use starlark::eval::Evaluator;
use starlark::environment::{Module, Globals};
use starlark::values::Value;
use starlark::syntax::{AstModule, Dialect};
fn main() {
// change filepath to the input file
let data = std::fs::read(filepath).unwrap();
let _ = match std::str::from_utf8(&data) {
Ok(d) => {
if let Ok(ast) = AstModule::parse("hello_world.star", d.to_owned(), &Dialect::Standard) {
let globals: Globals = Globals::standard();
let module: Module = Module::new();
let mut eval: Evaluator = Evaluator::new(&module, &globals);
eval.eval_module(ast);
}
},
Err(..) => return,
};
}
has output:
thread 'main' panicked at 'assertion failed: old_local.is_none()', /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:243:13
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic
3: starlark::eval::compiler::scope::Scope::collect_defines_in_def
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:243:13
4: starlark::eval::compiler::scope::Scope::collect_defines_recursively_in_expr
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:271:13
5: starlark::eval::compiler::scope::Scope::collect_defines_recursively::{{closure}}
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:264:34
6: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /home/sxia/code/rust-compiler/library/core/src/ops/function.rs:269:13
7: starlark::syntax::uniplate::<impl starlark::syntax::ast::StmtP<P>>::visit_children_mut::{{closure}}
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/syntax/uniplate.rs:110:45
8: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
at /home/sxia/code/rust-compiler/library/core/src/iter/traits/iterator.rs:722:29
9: core::iter::traits::iterator::Iterator::fold
at /home/sxia/code/rust-compiler/library/core/src/iter/traits/iterator.rs:2159:21
10: core::iter::traits::iterator::Iterator::for_each
at /home/sxia/code/rust-compiler/library/core/src/iter/traits/iterator.rs:725:9
11: starlark::syntax::uniplate::<impl starlark::syntax::ast::StmtP<P>>::visit_children_mut
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/syntax/uniplate.rs:110:17
12: starlark::eval::compiler::scope::Scope::collect_defines_recursively
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:263:9
13: starlark::eval::compiler::scope::Scope::collect_defines_recursively::{{closure}}
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:265:34
14: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
at /home/sxia/code/rust-compiler/library/core/src/ops/function.rs:269:13
15: starlark::syntax::uniplate::<impl starlark::syntax::ast::StmtP<P>>::visit_children_mut::{{closure}}
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/syntax/uniplate.rs:83:65
16: <core::slice::iter::IterMut<T> as core::iter::traits::iterator::Iterator>::for_each
at /home/sxia/code/rust-compiler/library/core/src/slice/iter/macros.rs:211:21
17: starlark::syntax::uniplate::<impl starlark::syntax::ast::StmtP<P>>::visit_children_mut
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/syntax/uniplate.rs:83:38
18: starlark::eval::compiler::scope::Scope::collect_defines_recursively
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:263:9
19: starlark::eval::compiler::scope::Scope::enter_module
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/compiler/scope.rs:195:9
20: starlark::eval::<impl starlark::eval::runtime::evaluator::Evaluator>::eval_module
at /home/sxia/.cargo/git/checkouts/starlark-rust-59575ffdf833204c/458a203/starlark/src/eval/mod.rs:98:25
...
Fixed in c963048, we weren't checking for duplicate parameters to lambda, which is now sorted - thanks for the report!