instn-named-bndng-dflt-gen-anon.js (2183B)
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: > 6 Imported binding reflects state of exported default binding ("anonymous" 7 generator function declaration) 8 esid: sec-moduledeclarationinstantiation 9 info: | 10 [...] 11 17. For each element d in lexDeclarations do 12 a. For each element dn of the BoundNames of d do 13 i. If IsConstantDeclaration of d is true, then 14 [...] 15 ii. Else, 16 1. Perform ! envRec.CreateMutableBinding(dn, false). 17 iii. If d is a GeneratorDeclaration production or a 18 FunctionDeclaration production, then 19 1. Let fo be the result of performing InstantiateFunctionObject 20 for d with argument env. 21 2. Call envRec.InitializeBinding(dn, fo). 22 [...] 23 24 14.4.12 Runtime Semantics: InstantiateFunctionObject 25 26 GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } 27 28 1. If the function code for GeneratorDeclaration is strict mode code, let 29 strict be true. Otherwise let strict be false. 30 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, 31 GeneratorBody, scope, strict). 32 3. Let prototype be ObjectCreate(%GeneratorPrototype%). 33 4. Perform DefinePropertyOrThrow(F, "prototype", 34 PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, 35 [[Enumerable]]: false, [[Configurable]]: false}). 36 5. Perform SetFunctionName(F, "default"). 37 6. Return F. 38 39 14.4 Generator Function Definitions 40 41 Syntax 42 43 GeneratorDeclaration[Yield, Default] : 44 function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody } 45 [+Default] function * ( FormalParameters[Yield] ) { GeneratorBody } 46 flags: [module] 47 features: [generators] 48 ---*/ 49 50 assert.sameValue(g().next().value, 23, 'generator function value is hoisted'); 51 assert.sameValue(g.name, 'default', 'correct name is assigned'); 52 53 import g from './instn-named-bndng-dflt-gen-anon.js'; 54 export default function* () { return 23; }; 55 56 reportCompare(0, 0);