summaryrefslogtreecommitdiff
path: root/Shell
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-07-07 17:16:01 +0430
committerAndreas Kling <kling@serenityos.org>2020-07-07 14:52:53 +0200
commitb5e04cb070b597ac848ed5222bf814db8a506726 (patch)
tree9d66a9acd113a71199796bb69f841043b718d5c3 /Shell
parentd86dbfe9e8c434d05ccabffeba51dbc1eabc900f (diff)
downloadserenity-b5e04cb070b597ac848ed5222bf814db8a506726.zip
Shell: Skip creating a Join node when nothing was parsed
This fixes a crash when Shell tries to highlight `|`.
Diffstat (limited to 'Shell')
-rw-r--r--Shell/Parser.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Shell/Parser.cpp b/Shell/Parser.cpp
index 70357de132..d7e038261a 100644
--- a/Shell/Parser.cpp
+++ b/Shell/Parser.cpp
@@ -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;