summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode.js
blob: 58d5a125b529b1fc943e92c868932a6c586e549c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (C) 2023 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-globaldeclarationinstantiation
description: Let binding collision with existing var declaration that was created for hoisted function.
info: |
  [...]
  3. For each element name of lexNames, do
    a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception.
flags: [noStrict]
---*/

eval('if (true) { function test262Fn() {} }');

assert.throws(SyntaxError, function() {
  $262.evalScript('var x; let test262Fn;');
});

assert.throws(ReferenceError, function() {
  x;
}, 'no bindings created');

reportCompare(0, 0);