Skip to content

Commit 02ab8b0

Browse files
fixed bug where error from previous cell is printed
1 parent d6abe14 commit 02ab8b0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/bin/lpython.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,12 @@ int interactive_python_repl(
847847
auto evaluation_start_time = std::chrono::high_resolution_clock::now();
848848
LCompilers::Result<LCompilers::PythonCompiler::EvalResult>
849849
res = fe.evaluate(code_string, false, lm, pass_manager, diagnostics);
850-
std::cerr << diagnostics.render(lm, compiler_options);
851850
if (res.ok) {
852851
r = res.result;
853852
} else {
854853
LCOMPILERS_ASSERT(diagnostics.has_error())
854+
std::cerr << diagnostics.render(lm, compiler_options);
855+
diagnostics.clear();
855856
code_string = "";
856857
std::cout << ">>> ";
857858
continue;

src/libasr/diagnostics.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ struct Diagnostics {
127127
diagnostics.push_back(d);
128128
}
129129

130+
void clear() {
131+
diagnostics.clear();
132+
}
133+
130134
void message_label(const std::string &message,
131135
const std::vector<Location> &locations,
132136
const std::string &error_label,

0 commit comments

Comments
 (0)