2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 description: Imported binding reflects state of exported `var` binding
6 esid: sec-moduledeclarationinstantiation
9 12. For each ImportEntry Record in in module.[[ImportEntries]], do
10 a. Let importedModule be ? HostResolveImportedModule(module,
11 in.[[ModuleRequest]]).
12 b. If in.[[ImportName]] is "*", then
15 i. Let resolution be ?
16 importedModule.ResolveExport(in.[[ImportName]], « », « »).
17 ii. If resolution is null or resolution is "ambiguous", throw a
18 SyntaxError exception.
19 iii. Call envRec.CreateImportBinding(in.[[LocalName]],
20 resolution.[[Module]], resolution.[[BindingName]]).
22 14. Let declaredVarNames be a new empty List.
23 15. For each element d in varDeclarations do
24 a. For each element dn of the BoundNames of d do
25 i. If dn is not an element of declaredVarNames, then
26 1. Perform ! envRec.CreateMutableBinding(dn, false).
27 2. Call envRec.InitializeBinding(dn, undefined).
28 3. Append dn to declaredVarNames.
31 8.1.1.5.5 CreateImportBinding
34 5. Create an immutable indirect binding in envRec for N that references M
35 and N2 as its target binding and record that the binding is initialized.
36 6. Return NormalCompletion(empty).
43 'binding is initialized to `undefined` prior to module evaulation'
46 assert.throws(TypeError, function() {
48 }, 'binding rejects assignment');
50 assert.sameValue(y, undefined, 'binding value is immutable');
52 import { x as y } from './instn-named-bndng-var.js';