tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

params-dflt-gen-meth-args-unmapped.js (3462B)


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