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.
6 Imported binding reflects state of exported default binding ("named"
7 generator function declaration)
8 esid: sec-moduledeclarationinstantiation
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
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).
24 14.4.12 Runtime Semantics: InstantiateFunctionObject
26 GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
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").
39 14.4 Generator Function Definitions
43 GeneratorDeclaration[Yield, Default] :
44 function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody }
45 [+Default] function * ( FormalParameters[Yield] ) { GeneratorBody }
47 features: [generators]
50 assert.sameValue(g().next().value, 23, 'generator function value is hoisted');
51 assert.sameValue(g.name, 'gName', 'correct name is assigned');
53 import g from './instn-named-bndng-dflt-gen-named.js';
54 export default function* gName() { return 23; };