diff --git a/Shell/AST.cpp b/Shell/AST.cpp index a1096eccd0..11f03c4ec2 100644 --- a/Shell/AST.cpp +++ b/Shell/AST.cpp @@ -1287,9 +1287,11 @@ RefPtr Sequence::run(RefPtr shell) // If we are to return a job, block on the left one then return the right one. if (would_execute()) { RefPtr execute_node = create(m_left->position(), m_left); - auto left_job = execute_node->run(shell); - ASSERT(left_job->is_job()); - shell->block_on_job(static_cast(left_job.ptr())->job()); + auto left_value = execute_node->run(shell); + // Some nodes are inherently empty, such as Comments and For loops without bodies, + // it is not an error for the value not to be a job. + if (left_value && left_value->is_job()) + shell->block_on_job(static_cast(left_value.ptr())->job()); if (m_right->would_execute()) return m_right->run(shell); diff --git a/Shell/AST.h b/Shell/AST.h index 9873bbbca8..3021940a11 100644 --- a/Shell/AST.h +++ b/Shell/AST.h @@ -589,6 +589,7 @@ private: virtual void highlight_in_editor(Line::Editor&, Shell&, HighlightMetadata = {}) override; virtual HitTestResult hit_test_position(size_t) override; virtual String class_name() const override { return "ForLoop"; } + virtual bool would_execute() const override { return true; } String m_variable_name; RefPtr m_iterated_expression;