New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 6 users
Status: Fixed
Owner:
Closed: Oct 2015
Cc:
HW: ----
NextAction: ----
OS: All
Priority: 3
Type: ----
ES5



Sign in to add a comment
Wrong completion value for try-finally
Reported by tothe...@gmail.com, Feb 6 2013 Back to list
The following code blocks differ only in dead code:

A: 
---
while(true) { 
  try{ 
    "try" ; 
    break 
  } finally { 
    "finally" 
  } 
}
---

B:
---
while(true) { 
  try{ 
    "try" ; 
    break 
  } finally { 
    "finally" 
  } ; 
  y = "done"
}
---

Since the loop is broken inside the try, the assignment never executes. And yet block A returns "finally" while block B returns "try".

Perhaps even more entertainingly:

C:
---
while(true) { 
  try{ 
    "try" ; 
    break 
  } finally { 
    "finally" 
  } ; 
  if(true){2} 
  else {var x = 3} 
}
---

D:
---
while(true) { 
  try{ 
    "try" ; 
    break 
  } finally { 
    "finally" 
  } ; 
  if(true){2} 
  else {3} 
}
---

C and D are identical except for some dead code, which is identical except for some even deader code (inside the false branch of the if). And yet C returns "finally" while D returns "try".
 
 Issue 2530  has been merged into this issue.
 Issue 2446  has been merged into this issue.
Labels: Priority-Low OS-All ES5
Status: Accepted
Summary: Wrong completion value for try-finally (was: Dead code changes the return value in try-finally blocks)
Will most likely be obsoleted in ES6 by http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform
Cc: rossberg@chromium.org
Comment 5 by habl...@google.com, Apr 29 2015
Status: Available
Comment 6 by adamk@chromium.org, Aug 13 2015
Owner: adamk@chromium.org
Comment 7 by adamk@chromium.org, Sep 29 2015
Owner: neis@chromium.org
Status: Assigned
Comment 9 by neis@chromium.org, Oct 1 2015
Status: Fixed
Labels: Priority-3
Sign in to add a comment