Shell: Mark ForLoop as would_execute

This fixes #2825.
This commit is contained in:
AnotherTest 2020-07-17 01:11:23 +04:30 committed by Andreas Kling
parent c969b8390d
commit 8e364b9780
Notes: sideshowbarker 2024-07-19 04:44:44 +09:00
2 changed files with 6 additions and 3 deletions

View file

@ -1287,9 +1287,11 @@ RefPtr<Value> Sequence::run(RefPtr<Shell> shell)
// If we are to return a job, block on the left one then return the right one.
if (would_execute()) {
RefPtr<AST::Node> execute_node = create<AST::Execute>(m_left->position(), m_left);
auto left_job = execute_node->run(shell);
ASSERT(left_job->is_job());
shell->block_on_job(static_cast<JobValue*>(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<JobValue*>(left_value.ptr())->job());
if (m_right->would_execute())
return m_right->run(shell);

View file

@ -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<AST::Node> m_iterated_expression;