starlight icon indicating copy to clipboard operation
starlight copied to clipboard

Support for "unsafe" cases of `finally`

Open playXE opened this issue 4 years ago • 1 comments

Starlight needs support for code like this:

function foo() {
  try {
      return 1;
  } finally {
      return 2;
  }
}

Right now it returns 1 but should return 2.

MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#the_finally-block

playXE avatar Feb 21 '21 06:02 playXE

Problem with implementing it is we down break and continue to single jumps which means finally can't be executed correctly and return is lowered to OP_RET which instantly returns, there could be one way to just jump to finally block on continue,break and return but this will not work as expected.

playXE avatar Feb 21 '21 06:02 playXE