ctorExpr-fn-ref-before-args-eval-fn-wrapup.js (1107B)
1 // Copyright (C) 2020 Leo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-new-operator 6 description: > 7 The constructExpr is referenced before arguments in the same EvaluateNew evaluation. 8 Function wrap-up to use the same function level binding ref. 9 info: | 10 NewExpression : new NewExpression 11 1. Return ? EvaluateNew(NewExpression, empty). 12 MemberExpression : new MemberExpression Arguments 13 1. Return ? EvaluateNew(MemberExpression, Arguments). 14 15 Runtime Semantics: EvaluateNew 16 17 3. Let ref be the result of evaluating constructExpr. 18 4. Let constructor be ? GetValue(ref). 19 5. If arguments is empty, let argList be a new empty List. 20 6. Else, 21 a. Let argList be ? ArgumentListEvaluation of arguments. 22 7. If IsConstructor(constructor) is false, throw a TypeError exception. 23 8. Return ? Construct(constructor, argList). 24 ---*/ 25 26 function fn() { 27 var x = function() { 28 this.foo = 42; 29 }; 30 31 var result = new x(x = 1); 32 33 assert.sameValue(x, 1); 34 assert.sameValue(result.foo, 42); 35 } 36 37 fn(); 38 39 reportCompare(0, 0);