params-dflt-gen-meth-args-unmapped.js (3561B)
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, _ = 0) { 76 assert.sameValue(x, undefined, 'parameter binding value (initial)'); 77 assert.sameValue( 78 arguments[0], undefined, 'arguments property value (initial)' 79 ); 80 81 arguments[0] = 1; 82 83 assert.sameValue( 84 x, undefined, 'parameter binding value (after arguments modification)' 85 ); 86 assert.sameValue( 87 arguments[0], 1, 'arguments property value (after arguments modification)' 88 ); 89 90 x = 2; 91 92 assert.sameValue( 93 x, 2, 'parameter binding value (after parameter binding modification)' 94 ); 95 assert.sameValue( 96 arguments[0], 97 1, 98 'arguments property value (after parameter binding modification)' 99 ); 100 callCount = callCount + 1; 101 } 102 }; 103 104 C.prototype.method().next(); 105 106 assert.sameValue(callCount, 1, 'method invoked exactly once'); 107 108 reportCompare(0, 0);