Shell: Skip creating a Join node when nothing was parsed

This fixes a crash when Shell tries to highlight `|`.
This commit is contained in:
AnotherTest 2020-07-07 17:16:01 +04:30 committed by Andreas Kling
parent d86dbfe9e8
commit b5e04cb070
Notes: sideshowbarker 2024-07-19 05:02:38 +09:00

View File

@ -123,7 +123,10 @@ RefPtr<AST::Node> Parser::parse()
// Parsing stopped midway, this is a syntax error.
auto error_start = push_start();
m_offset = m_input.length();
return create<AST::Join>(move(toplevel), create<AST::SyntaxError>("Unexpected tokens past the end"));
auto syntax_error_node = create<AST::SyntaxError>("Unexpected tokens past the end");
if (toplevel)
return create<AST::Join>(move(toplevel), move(syntax_error_node));
return syntax_error_node;
}
return toplevel;