diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.cpp b/Userland/Libraries/LibJS/Bytecode/Generator.cpp index aeaf5956446..1315f202627 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Generator.cpp @@ -902,7 +902,6 @@ void Generator::generate_scoped_jump(JumpType type) } break; case Unwind: - VERIFY(last_was_finally || !m_current_unwind_context->finalizer().has_value()); if (!last_was_finally) { VERIFY(m_current_unwind_context && m_current_unwind_context->handler().has_value()); emit(); @@ -944,7 +943,6 @@ void Generator::generate_labelled_jump(JumpType type, DeprecatedFlyString const& for (; current_boundary > 0; --current_boundary) { auto boundary = m_boundaries[current_boundary - 1]; if (boundary == BlockBoundaryType::Unwind) { - VERIFY(last_was_finally || !m_current_unwind_context->finalizer().has_value()); if (!last_was_finally) { VERIFY(m_current_unwind_context && m_current_unwind_context->handler().has_value()); emit(); diff --git a/Userland/Libraries/LibJS/Tests/try-finally-break.js b/Userland/Libraries/LibJS/Tests/try-finally-break.js index 76c4cf72ed5..162c3ed5da1 100644 --- a/Userland/Libraries/LibJS/Tests/try-finally-break.js +++ b/Userland/Libraries/LibJS/Tests/try-finally-break.js @@ -450,3 +450,43 @@ test("Throw while breaking with nested try-catch-finally with throw in finalizer expect(executionOrder).toEqual([1, 2, 3, 4, 5]); }); + +test("Labelled break with nested mixed try-catch/finally", () => { + const executionOrder = []; + scope: { + try { + try { + executionOrder.push(1); + break scope; + } catch { + expect.fail("Entered catch"); + } + expect.fail("Continued after inner try"); + } finally { + executionOrder.push(2); + } + expect.fail("Continued after outer try"); + } + + expect(executionOrder).toEqual([1, 2]); +}); + +test("Break with nested mixed try-catch/finally", () => { + const executionOrder = []; + do { + try { + try { + executionOrder.push(1); + break; + } catch { + expect.fail("Entered catch"); + } + expect.fail("Continued after inner try"); + } finally { + executionOrder.push(2); + } + expect.fail("Continued after outer try"); + } while (expect.fail("Continued after do-while loop")); + + expect(executionOrder).toEqual([1, 2]); +});