| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
description: Referencing the arguments object from a default parameter (class expression method) |
| 5 |
esid: sec-class-definitions-runtime-semantics-evaluation |
| 6 |
es6id: 14.5.16 |
| 7 |
features: [generators, default-parameters] |
| 8 |
info: | |
| 9 |
ClassExpression : class BindingIdentifieropt ClassTail |
| 10 |
|
| 11 |
1. If BindingIdentifieropt is not present, let className be undefined. |
| 12 |
2. Else, let className be StringValue of BindingIdentifier. |
| 13 |
3. Let value be the result of ClassDefinitionEvaluation of ClassTail |
| 14 |
with argument className. |
| 15 |
[...] |
| 16 |
|
| 17 |
14.5.14 Runtime Semantics: ClassDefinitionEvaluation |
| 18 |
|
| 19 |
21. For each ClassElement m in order from methods |
| 20 |
a. If IsStatic of m is false, then |
| 21 |
i. Let status be the result of performing |
| 22 |
PropertyDefinitionEvaluation for m with arguments proto and |
| 23 |
false. |
| 24 |
[...] |
| 25 |
|
| 26 |
14.4.13 Runtime Semantics: PropertyDefinitionEvaluation |
| 27 |
|
| 28 |
GeneratorMethod : |
| 29 |
* PropertyName ( StrictFormalParameters ) { GeneratorBody } |
| 30 |
|
| 31 |
1. Let propKey be the result of evaluating PropertyName. |
| 32 |
2. ReturnIfAbrupt(propKey). |
| 33 |
3. If the function code for this GeneratorMethod is strict mode code, |
| 34 |
let strict be true. Otherwise let strict be false. |
| 35 |
4. Let scope be the running execution context's LexicalEnvironment. |
| 36 |
5. Let closure be GeneratorFunctionCreate(Method, |
| 37 |
StrictFormalParameters, GeneratorBody, scope, strict). |
| 38 |
|
| 39 |
9.2.1 [[Call]] ( thisArgument, argumentsList) |
| 40 |
|
| 41 |
[...] |
| 42 |
7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). |
| 43 |
[...] |
| 44 |
|
| 45 |
9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) |
| 46 |
|
| 47 |
1. Let status be FunctionDeclarationInstantiation(F, argumentsList). |
| 48 |
[...] |
| 49 |
|
| 50 |
9.2.12 FunctionDeclarationInstantiation(func, argumentsList) |
| 51 |
|
| 52 |
[...] |
| 53 |
23. Let iteratorRecord be Record {[[iterator]]: |
| 54 |
CreateListIterator(argumentsList), [[done]]: false}. |
| 55 |
24. If hasDuplicates is true, then |
| 56 |
[...] |
| 57 |
25. Else, |
| 58 |
b. Let formalStatus be IteratorBindingInitialization for formals with |
| 59 |
iteratorRecord and env as arguments. |
| 60 |
[...] |
| 61 |
|
| 62 |
14.1.19 Runtime Semantics: IteratorBindingInitialization |
| 63 |
|
| 64 |
FormalsList : FormalsList , FormalParameter |
| 65 |
|
| 66 |
1. Let status be the result of performing IteratorBindingInitialization for |
| 67 |
FormalsList using iteratorRecord and environment as the arguments. |
| 68 |
2. ReturnIfAbrupt(status). |
| 69 |
3. Return the result of performing IteratorBindingInitialization for |
| 70 |
FormalParameter using iteratorRecord and environment as the arguments. |
| 71 |
---*/ |
| 72 |
|
| 73 |
var callCount = 0; |
| 74 |
var C = class { |
| 75 |
*method(x = arguments[2], y = arguments[3], z) { |
| 76 |
assert.sameValue(x, 'third', 'first parameter'); |
| 77 |
assert.sameValue(y, 'fourth', 'second parameter'); |
| 78 |
assert.sameValue(z, 'third', 'third parameter'); |
| 79 |
callCount = callCount + 1; |
| 80 |
} |
| 81 |
}; |
| 82 |
|
| 83 |
C.prototype.method(undefined, undefined, 'third', 'fourth').next(); |
| 84 |
|
| 85 |
assert.sameValue(callCount, 1, 'method invoked exactly once'); |