lex-env-distinct-const.js (912B)
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-performeval 5 description: > 6 Indirect eval code creates a new declarative environment for 7 lexically-scoped declarations (const) 8 info: | 9 [...] 10 9. If direct is true, then 11 [...] 12 10. Else, 13 a. Let lexEnv be NewDeclarativeEnvironment(evalRealm.[[GlobalEnv]]). 14 [...] 15 features: [const] 16 ---*/ 17 18 const outside = null; 19 20 (0,eval)('const outside = null;'); 21 (0,eval)('"use strict"; const outside = null;'); 22 23 (0,eval)('const xNonStrict = null;'); 24 25 assert.sameValue(typeof xNonStrict, 'undefined'); 26 assert.throws(ReferenceError, function() { 27 xNonStrict; 28 }); 29 30 (0,eval)('"use strict"; const xStrict = null;'); 31 32 assert.sameValue(typeof xStrict, 'undefined'); 33 assert.throws(ReferenceError, function() { 34 xStrict; 35 }); 36 37 reportCompare(0, 0);