| 1 |
// |reftest| module |
| 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. |
| 4 |
/*--- |
| 5 |
description: Imported binding reflects state of exported `const` binding |
| 6 |
esid: sec-moduledeclarationinstantiation |
| 7 |
info: | |
| 8 |
[...] |
| 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 |
| 13 |
[...] |
| 14 |
c. Else, |
| 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]]). |
| 21 |
[...] |
| 22 |
16. Let lexDeclarations be the LexicallyScopedDeclarations of code. |
| 23 |
17. For each element d in lexDeclarations do |
| 24 |
a. For each element dn of the BoundNames of d do |
| 25 |
i, If IsConstantDeclaration of d is true, then |
| 26 |
1. Perform ! envRec.CreateImmutableBinding(dn, true). |
| 27 |
ii. Else, |
| 28 |
1. Perform ! envRec.CreateMutableBinding(dn, false). |
| 29 |
iii. If d is a GeneratorDeclaration production or a |
| 30 |
FunctionDeclaration production, then |
| 31 |
[...] |
| 32 |
|
| 33 |
8.1.1.5.5 CreateImportBinding |
| 34 |
|
| 35 |
[...] |
| 36 |
5. Create an immutable indirect binding in envRec for N that references M |
| 37 |
and N2 as its target binding and record that the binding is initialized. |
| 38 |
6. Return NormalCompletion(empty). |
| 39 |
flags: [module] |
| 40 |
---*/ |
| 41 |
|
| 42 |
assert.throws(ReferenceError, function() { |
| 43 |
typeof y; |
| 44 |
}, 'binding is created but not initialized'); |
| 45 |
|
| 46 |
import { x as y } from './instn-named-bndng-let.js'; |
| 47 |
export let x = 23; |
| 48 |
|
| 49 |
reportCompare(0, 0); |