New issue
Advanced search Search tips
Starred by 4 users
Status: Duplicate
Merged: issue 2529
Owner: ----
Closed: Feb 2013
HW: ----
NextAction: ----
OS: ----
Priority: ----
Type: ----

Sign in to add a comment
try-finally should return try's completion value if finally returned normally
Reported by, Dec 6 2012 Back to list
Steps to reproduce:

Test case:
try{ "try-value" }finally{ "finally-value" }

Expected results:

Per [ES5.1, 12.14 The try Statement], the code should return "try-value", but V8, JSC, IE and Spidermonkey return "finally-value". Opera does return "try-value".
Comment 1 by, Feb 6 2013
Note also that the letter of ES5.1 12.14 suggests that if the finally block returns non-normally, it is the result of the finally block that should be returned. So:

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

... should return "finally-value". V8 and SpiderMonkey return "finally-value" here, while Opera returns "try-value".
Opera apparently never returns a completion value from a finally block, that's why they return "try-value" in the first example. Maybe [1] will bring more consistent results across browsers in the future. More tests can be found at [2].

Mergedinto: 2529
Status: Duplicate
Sign in to add a comment