params-dflt-meth-args-unmapped.js (3361B)
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: [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.3.8 Runtime Semantics: DefineMethod 27 28 MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } 29 30 [...] 31 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, 32 scope, strict). If functionPrototype was passed as a parameter then pass its 33 value as the functionPrototype optional argument of FunctionCreate. 34 [...] 35 36 9.2.1 [[Call]] ( thisArgument, argumentsList) 37 38 [...] 39 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). 40 [...] 41 42 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) 43 44 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). 45 [...] 46 47 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) 48 49 [...] 50 23. Let iteratorRecord be Record {[[iterator]]: 51 CreateListIterator(argumentsList), [[done]]: false}. 52 24. If hasDuplicates is true, then 53 [...] 54 25. Else, 55 b. Let formalStatus be IteratorBindingInitialization for formals with 56 iteratorRecord and env as arguments. 57 [...] 58 59 14.1.19 Runtime Semantics: IteratorBindingInitialization 60 61 FormalsList : FormalsList , FormalParameter 62 63 1. Let status be the result of performing IteratorBindingInitialization for 64 FormalsList using iteratorRecord and environment as the arguments. 65 2. ReturnIfAbrupt(status). 66 3. Return the result of performing IteratorBindingInitialization for 67 FormalParameter using iteratorRecord and environment as the arguments. 68 ---*/ 69 70 var callCount = 0; 71 var C = class { 72 method(x, _ = 0) { 73 assert.sameValue(x, undefined, 'parameter binding value (initial)'); 74 assert.sameValue( 75 arguments[0], undefined, 'arguments property value (initial)' 76 ); 77 78 arguments[0] = 1; 79 80 assert.sameValue( 81 x, undefined, 'parameter binding value (after arguments modification)' 82 ); 83 assert.sameValue( 84 arguments[0], 1, 'arguments property value (after arguments modification)' 85 ); 86 87 x = 2; 88 89 assert.sameValue( 90 x, 2, 'parameter binding value (after parameter binding modification)' 91 ); 92 assert.sameValue( 93 arguments[0], 94 1, 95 'arguments property value (after parameter binding modification)' 96 ); 97 callCount = callCount + 1; 98 } 99 }; 100 101 C.prototype.method(); 102 103 assert.sameValue(callCount, 1, 'method invoked exactly once'); 104 105 reportCompare(0, 0);