LibJS: Fix return statements not working properly in loops

Previously, when a loop detected an unwind of type ScopeType::Function
(which means a return statement was executed inside of the loop), it
would just return undefined. This set the VM's last_value to undefined,
when it should have been the returned value. This patch makes all loop
statements return the appropriate value in the above case.
This commit is contained in:
Matthew Olsson 2020-10-08 13:17:40 -07:00 committed by Andreas Kling
commit 6e05685ad4
Notes: sideshowbarker 2024-07-19 01:57:27 +09:00
3 changed files with 59 additions and 8 deletions

View file

@ -167,7 +167,7 @@ public:
m_unwind_until_label = label;
}
void stop_unwind() { m_unwind_until = ScopeType::None; }
bool should_unwind_until(ScopeType type, FlyString label) const
bool should_unwind_until(ScopeType type, FlyString label = {}) const
{
if (m_unwind_until_label.is_null())
return m_unwind_until == type;