params-dflt-gen-meth-ref-arguments.js (3032B)
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 ClassDeclaration : class BindingIdentifier ClassTail 10 11 1. Let className be StringValue of BindingIdentifier. 12 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with 13 argument className. 14 [...] 15 16 14.5.14 Runtime Semantics: ClassDefinitionEvaluation 17 18 21. For each ClassElement m in order from methods 19 a. If IsStatic of m is false, then 20 i. Let status be the result of performing 21 PropertyDefinitionEvaluation for m with arguments proto and 22 false. 23 [...] 24 25 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation 26 27 GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } 28 29 1. Let propKey be the result of evaluating PropertyName. 30 2. ReturnIfAbrupt(propKey). 31 3. If the function code for this GeneratorMethod is strict mode code, 32 let strict be true. Otherwise let strict be false. 33 4. Let scope be the running execution context's LexicalEnvironment. 34 5. Let closure be GeneratorFunctionCreate(Method, 35 StrictFormalParameters, GeneratorBody, scope, strict). 36 37 9.2.1 [[Call]] ( thisArgument, argumentsList) 38 39 [...] 40 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). 41 [...] 42 43 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) 44 45 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). 46 [...] 47 48 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) 49 50 [...] 51 23. Let iteratorRecord be Record {[[iterator]]: 52 CreateListIterator(argumentsList), [[done]]: false}. 53 24. If hasDuplicates is true, then 54 [...] 55 25. Else, 56 b. Let formalStatus be IteratorBindingInitialization for formals with 57 iteratorRecord and env as arguments. 58 [...] 59 60 14.1.19 Runtime Semantics: IteratorBindingInitialization 61 62 FormalsList : FormalsList , FormalParameter 63 64 1. Let status be the result of performing IteratorBindingInitialization for 65 FormalsList using iteratorRecord and environment as the arguments. 66 2. ReturnIfAbrupt(status). 67 3. Return the result of performing IteratorBindingInitialization for 68 FormalParameter using iteratorRecord and environment as the arguments. 69 ---*/ 70 71 var callCount = 0; 72 class C { 73 *method(x = arguments[2], y = arguments[3], z) { 74 assert.sameValue(x, 'third', 'first parameter'); 75 assert.sameValue(y, 'fourth', 'second parameter'); 76 assert.sameValue(z, 'third', 'third parameter'); 77 callCount = callCount + 1; 78 } 79 } 80 81 C.prototype.method(undefined, undefined, 'third', 'fourth').next(); 82 83 assert.sameValue(callCount, 1, 'method invoked exactly once'); 84 85 reportCompare(0, 0);