1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject
description: >
Initializer is not evaluated when argument is an object with
[[IsHTMLDDA]] internal slot.
info: |
FunctionDeclaration :
function BindingIdentifier ( FormalParameters ) { FunctionBody }
[...]
3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody,
scope, strict).
[...]
[[Call]] ( thisArgument, argumentsList)
[...]
7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
[...]
OrdinaryCallEvaluateBody ( F, argumentsList )
1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
[...]
FunctionDeclarationInstantiation(func, argumentsList)
[...]
23. Let iteratorRecord be Record {[[iterator]]:
CreateListIterator(argumentsList), [[done]]: false}.
24. If hasDuplicates is true, then
[...]
25. Else,
b. Let formalStatus be IteratorBindingInitialization for formals with
iteratorRecord and env as arguments.
[...]
Runtime Semantics: IteratorBindingInitialization
FormalsList : FormalsList , FormalParameter
[...]
23. Let iteratorRecord be Record {[[Iterator]]:
CreateListIterator(argumentsList), [[Done]]: false}.
24. If hasDuplicates is true, then
[...]
25. Else,
a. Perform ? IteratorBindingInitialization for formals with
iteratorRecord and env as arguments.
[...]
features: [default-parameters, IsHTMLDDA]
---*/
let initCount = 0;
const counter = function() {
initCount += 1;
};
const arrow = (x = counter()) => x;
const IsHTMLDDA = $262.IsHTMLDDA;
assert.sameValue(arrow(IsHTMLDDA), IsHTMLDDA);
assert.sameValue(initCount, 0);
function fn(x, y = counter()) {
return y;
}
assert.sameValue(fn(1, IsHTMLDDA), IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);
|