Debian Codegraph @

js/src/tests/test262/language/eval-code/indirect/var-env-global-lex-non-strict.js

raw
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-evaldeclarationinstantiation
5 description: Variable collision with global lexical binding
6 info: |
7 [...]
8 5. If strict is false, then
9 a. If varEnvRec is a global Environment Record, then
10 i. For each name in varNames, do
11 1. If varEnvRec.HasLexicalDeclaration(name) is true, throw a
12 SyntaxError exception.
13 2. NOTE: eval will not create a global var declaration that would
14 be shadowed by a global lexical declaration.
15 [...]
16 features: [let]
17 ---*/
18
19 let x;
20 var caught;
21
22 // The `assert.throws` helper function would interfere with the semantics under
23 // test.
24 try {
25 (0,eval)('var x;');
26 } catch (err) {
27 caught = err;
28 }
29
30 assert.notSameValue(caught, undefined);
31 assert.sameValue(caught.constructor, SyntaxError);
32
33 reportCompare(0, 0);