Normally, if a function contains an inner loop and an outer loop, a return statement will exit the whole function.
Since buble transforms loops into functions, in order to preserve this behaviour there is a test for whether there is a returned value from the inner loop, and if so, we break out of the outer loop as well.
However, the test for whether there is a returned value is whether the return value is truthy. So if you return false, or undefined or zero, the outer loop will continue, causing some very had to diagnose and unintuitive bugs, especially when hidden away by sourcemaps.
This PR improves on the current implementation by testing whether the return value is defined. It isn't a perfect solution since you could have a return statement with no return value, and that would also fail to exit the function. However, I don't really understand the codebase enough yet to suggest a better solution and this is probably better than nothing.
Normally, if a function contains an inner loop and an outer loop, a return statement will exit the whole function.
Since buble transforms loops into functions, in order to preserve this behaviour there is a test for whether there is a returned value from the inner loop, and if so, we break out of the outer loop as well.
However, the test for whether there is a returned value is whether the return value is truthy. So if you return false, or undefined or zero, the outer loop will continue, causing some very had to diagnose and unintuitive bugs, especially when hidden away by sourcemaps.
This PR improves on the current implementation by testing whether the return value is defined. It isn't a perfect solution since you could have a return statement with no return value, and that would also fail to exit the function. However, I don't really understand the codebase enough yet to suggest a better solution and this is probably better than nothing.