Spreadsheet: Check for parse errors after parsing the source

There won't be any parse errors before we actually try to parse
something.
Fixes input like "=1+" crashing the spreadsheet instead of just causing
an error in the cell.
This commit is contained in:
AnotherTest 2021-03-22 16:53:18 +04:30 committed by Andreas Kling
commit 7b4fa860d2
Notes: sideshowbarker 2024-07-18 21:08:34 +09:00

View file

@ -199,10 +199,10 @@ Sheet::ValueAndException Sheet::evaluate(const StringView& source, Cell* on_beha
ScopeGuard clear_exception { [&] { interpreter().vm().clear_exception(); } };
auto parser = JS::Parser(JS::Lexer(source));
auto program = parser.parse_program();
if (parser.has_errors() || interpreter().exception())
return { JS::js_undefined(), interpreter().exception() };
auto program = parser.parse_program();
interpreter().run(global_object(), program);
if (interpreter().exception()) {
auto exc = interpreter().exception();