| 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 |
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.1.20 Runtime Semantics: InstantiateFunctionObject |
| 25 |
|
| 26 |
FunctionDeclaration : function ( FormalParameters ) { FunctionBody } |
| 27 |
|
| 28 |
1. If the function code for FunctionDeclaration is strict mode code, let |
| 29 |
strict be true. Otherwise let strict be false. |
| 30 |
2. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, scope, |
| 31 |
strict). |
| 32 |
3. Perform MakeConstructor(F). |
| 33 |
4. Perform SetFunctionName(F, "default"). |
| 34 |
5. Return F. |
| 35 |
|
| 36 |
14.1 Function Definitions |
| 37 |
|
| 38 |
Syntax |
| 39 |
|
| 40 |
FunctionDeclaration[Yield, Default] : |
| 41 |
|
| 42 |
function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } |
| 43 |
[+Default] function ( FormalParameters ) { FunctionBody } |
| 44 |
flags: [module] |
| 45 |
---*/ |
| 46 |
|
| 47 |
assert.sameValue(f(), 23, 'function value is hoisted'); |
| 48 |
assert.sameValue(f.name, 'default', 'correct name is assigned'); |
| 49 |
|
| 50 |
import f from './instn-named-bndng-dflt-fun-anon.js'; |
| 51 |
export default function() { return 23; }; |
| 52 |
|
| 53 |
reportCompare(0, 0); |