scope-catch-param-var-none.js (945B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-runtime-semantics-catchclauseevaluation 5 description: Retainment of existing variable environment for `catch` parameter 6 flags: [noStrict] 7 ---*/ 8 9 var x = 1; 10 var probeBefore = function() { return x; }; 11 var probeTry, probeParam, probeBlock; 12 13 try { 14 var x = 2; 15 probeTry = function() { return x; }; 16 throw []; 17 } catch ([_ = (eval('var x = 3;'), probeParam = function() { return x; })]) { 18 var x = 4; 19 probeBlock = function() { return x; }; 20 } 21 22 assert.sameValue(probeBefore(), 4, 'reference preceding statement'); 23 assert.sameValue(probeTry(), 4, 'reference from `try` block'); 24 assert.sameValue(probeParam(), 4, 'reference within CatchParameter'); 25 assert.sameValue(probeBlock(), 4, 'reference from `catch` block'); 26 assert.sameValue(x, 4, 'reference following statement'); 27 28 reportCompare(0, 0);