LibJS+LibWeb: Let JS::Script::parse() return a list of errors (on error)

These are really supposed to be a list of SyntaxError objects, but for
now we simply return all the Parser::Error objects we got from Parser.
This commit is contained in:
Andreas Kling 2021-09-14 20:56:57 +02:00
parent 5fa02b8a9e
commit 10c489713d
Notes: sideshowbarker 2024-07-18 03:58:00 +09:00
3 changed files with 17 additions and 8 deletions

View file

@ -38,12 +38,17 @@ NonnullRefPtr<ClassicScript> ClassicScript::create(String filename, StringView s
// 10. Let result be ParseScript(source, settings's Realm, script).
auto result = JS::Script::parse(source, realm, script->filename());
// FIXME: 11. If result is a list of errors, then:
// 1. Set script's parse error and its error to rethrow to result[0].
// 2. Return script.
// 11. If result is a list of errors, then:
if (result.is_error()) {
// FIXME: 1. Set script's parse error and its error to rethrow to result[0].
// 2. Return script.
return script;
}
// 12. Set script's record to result.
script->m_script_record = move(result);
script->m_script_record = result.release_value();
// 13. Return script.
return script;