Running the following code in v8 I get:
0 var f = 0; 1 2 (function () 3 { 4 try 5 { 6 throw 1; 7 } catch (f) 8 { 9 print(f); // print 1 10 f = 2; 11 print(f); // print 2 12 } 13 print(f); // print 0 14 })();
However, replacing line 11 by
var f = 2;
will print 'undefined' at line 13 instead of '0'. Which means that although catch introduces a lexical binding for f, a var statement with the same name inside a catch block introduces a local variable spanning the whole function. However, the assignation is still made on the variable local to the catch statement!
I'll look at the standard to understand how this could be explained.
Ah JavaScript, you would not be the same without all your little quirks...
Erick