mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
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:
parent
d980073122
commit
6e05685ad4
3 changed files with 59 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue