test262/test/annexB/language/global-code/script-decl-lex-collision.js
Alexey Shvayka be53234590
Test that HasVarDeclaration accounts for bindings created via eval() (#3914)
Co-authored-by: Alexey Shvayka <ashvayka@apple.com>
2023-09-28 18:16:33 +02:00

24 lines
648 B
JavaScript

// 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]
---*/
if (true) {
function test262Fn() {}
}
assert.throws(SyntaxError, function() {
$262.evalScript('var x; let test262Fn;');
});
assert.throws(ReferenceError, function() {
x;
}, 'no bindings created');