quickjs-done-nextgen/tests/bug741.js
Ben Noordhuis 66732e78ef
Fix break statement in presence of labels (#742)
In this snippet...

    for (;;) label: break

...the break statement jumped back to the start of the loop instead of
*out* of the loop.

Fixes: https://github.com/quickjs-ng/quickjs/issues/741
2024-12-04 23:56:52 +01:00

19 lines
246 B
JavaScript

import {assert} from "./assert.js"
while (1) label: break
var i = 0
while (i < 3) label: {
if (i > 0)
break
i++
}
assert(i, 1)
for (;;) label: break
for (i = 0; i < 3; i++) label: {
if (i > 0)
break
}
assert(i, 1)