Skip to content

Commit

Permalink
fix functions in the repl
Browse files Browse the repository at this point in the history
closes #339
  • Loading branch information
kaikalii committed Jan 5, 2024
1 parent 91c5332 commit 57a2669
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ impl Assembly {
self.bindings.push(binding);
}
}
/// Make top-level expressions not run
pub fn remove_top_level(&mut self) {
self.top_slices.clear();
}
}

impl AsRef<Assembly> for Assembly {
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,9 @@ fn repl(mut rt: Uiua, mut compiler: Compiler, color: bool, config: FormatConfig)
.and_then(|comp| rt.run_asm(comp.finish()));
print_stack(&rt.take_stack(), color);
match res {
Ok(asm) => {
compiler.assembly_mut().bindings = asm.bindings;
Ok(mut asm) => {
asm.remove_top_level();
*compiler.assembly_mut() = asm;
Ok(true)
}
Err(e) => {
Expand Down

0 comments on commit 57a2669

Please sign in to comment.