catch-redeclared-for-of-var.js (810B)
1 // Copyright (C) 2019 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 author: Ross Kirsling 5 esid: sec-variablestatements-in-catch-blocks 6 description: Re-declaration of catch parameter (for-of statement) 7 info: | 8 It is a Syntax Error if any element of the BoundNames of CatchParameter 9 also occurs in the VarDeclaredNames of Block, unless CatchParameter is 10 CatchParameter : BindingIdentifier. 11 ---*/ 12 13 var before, during, after; 14 15 try { 16 throw 'exception'; 17 } catch (err) { 18 before = err; 19 for (var err of [2]) { 20 during = err; 21 } 22 after = err; 23 } 24 25 assert.sameValue(before, 'exception'); 26 assert.sameValue(during, 2, 'during loop body evaluation'); 27 assert.sameValue(after, 2, 'after loop body evaluation'); 28 29 reportCompare(0, 0);