1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:47:35 +00:00

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
parent fef165f1d2
commit 7b4fa860d2

View file

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