From d7fce01823916a639101cdcaf179e1ea1ebfdbba Mon Sep 17 00:00:00 2001 From: Alex van de Sandt Date: Wed, 10 Jul 2024 18:15:17 -0400 Subject: [PATCH] Don't exit repl after runtime error --- src/runners/repl.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/runners/repl.rs b/src/runners/repl.rs index 224c544..7a899c2 100644 --- a/src/runners/repl.rs +++ b/src/runners/repl.rs @@ -61,9 +61,13 @@ pub fn run_repl() -> Result<()> { }; println!("{}", ast.print_rpn()); - interpreter - .interpret(&ast) - .map_err(|e| Report::new(e).with_source_code(line.clone()))?; + if let Err(e) = interpreter.interpret(&ast) { + let report = Report::new(e).with_source_code(line.clone()); + eprintln!("{report:?}"); + + prompt()?; + continue; + } prompt()?; } -- 2.51.2