instn-named-bndng-fun.js (2249B)
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 function 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 1. Let fo be the result of performing InstantiateFunctionObject 32 for d with argument env. 33 2. Call envRec.InitializeBinding(dn, fo). 34 [...] 35 36 8.1.1.5.5 CreateImportBinding 37 38 [...] 39 5. Create an immutable indirect binding in envRec for N that references M 40 and N2 as its target binding and record that the binding is initialized. 41 6. Return NormalCompletion(empty). 42 flags: [module] 43 ---*/ 44 45 assert.sameValue( 46 f2(), 47 23, 48 'binding is initialized to function value prior to module evaluation' 49 ); 50 51 assert.throws(TypeError, function() { 52 f2 = null; 53 }, 'binding rejects assignment'); 54 55 assert.sameValue(f2(), 23, 'binding value is immutable'); 56 57 import { f as f2 } from './instn-named-bndng-fun.js'; 58 export function f() { return 23; } 59 60 reportCompare(0, 0);