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