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